From 284059615c9a1e5ffe0b2d437efe70a24565c70c Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 26 Feb 2019 17:43:37 +0100 Subject: [PATCH 1/4] Changes for standard proton reco validation --- .../interface/AnalysisEvent.h | 758 +++++++ GammaGammaLeptonLepton/interface/HLTMatcher.h | 30 +- .../interface/PrimaryVertexSelector.h | 51 +- .../interface/ProtonKinematics.h | 66 + .../interface/SinglePhotonEvent.h | 321 +++ .../plugins/GammaGammaLL.cc | 2020 ++++++++--------- GammaGammaLeptonLepton/plugins/GammaGammaLL.h | 391 ---- .../plugins/SinglePhotonTreeProducer.cc | 312 +++ .../python/GammaGammaLL_cfi.py | 86 +- .../python/singlePhotonTreeProducer_cfi.py | 16 + .../test/RunGammaGammaLeptonLepton_cfg.py | 215 +- 11 files changed, 2581 insertions(+), 1685 deletions(-) create mode 100644 GammaGammaLeptonLepton/interface/AnalysisEvent.h create mode 100644 GammaGammaLeptonLepton/interface/ProtonKinematics.h create mode 100644 GammaGammaLeptonLepton/interface/SinglePhotonEvent.h delete mode 100644 GammaGammaLeptonLepton/plugins/GammaGammaLL.h create mode 100644 GammaGammaLeptonLepton/plugins/SinglePhotonTreeProducer.cc create mode 100644 GammaGammaLeptonLepton/python/singlePhotonTreeProducer_cfi.py diff --git a/GammaGammaLeptonLepton/interface/AnalysisEvent.h b/GammaGammaLeptonLepton/interface/AnalysisEvent.h new file mode 100644 index 0000000..35ed713 --- /dev/null +++ b/GammaGammaLeptonLepton/interface/AnalysisEvent.h @@ -0,0 +1,758 @@ +#ifndef DiffractiveForwardAnalysis_GammaGammaLeptonLepton_AnalysisEvent_h +#define DiffractiveForwardAnalysis_GammaGammaLeptonLepton_AnalysisEvent_h + +#include +#include + +#include "TTree.h" + +namespace ggll +{ + enum TreeType { + invalidTree = -1, + DiMuon, + DiElectron, + ElectronMuon + }; + + class AnalysisEvent + { + public: + AnalysisEvent() : + HLT_Name( new std::vector() ) { + clear(); + } + ~AnalysisEvent() { + if ( HLT_Name ) delete HLT_Name; + } + + ////// Leaves size ////// + + /// Maximum number of HLT to check + static constexpr unsigned int MAX_HLT = 10; + /// Maximum number of leptons per event + static constexpr unsigned int MAX_LL = 50; + /// Maximum number of muons per event + static constexpr unsigned int MAX_MUONS = 25; + /// Maximum number of electrons per event + static constexpr unsigned int MAX_ELE = 25; + /// Maximum number of photons per event + static constexpr unsigned int MAX_PHO = 50; + /// Maximum number of leptons pairs per event + static constexpr unsigned int MAX_PAIRS = 25; + static constexpr unsigned int MAX_PAIRPHO = 25; + /// Maximum number of primary vertices per event + static constexpr unsigned int MAX_VTX = 150; + /// Maximum number of extra tracks per event + static constexpr unsigned int MAX_ET = 1000; + /// Maximum number of generator level muons per event + static constexpr unsigned int MAX_GENMU = 25; + /// Maximum number of generator level electrons per event + static constexpr unsigned int MAX_GENELE = 25; + /// Maximum number of generator level photons per event + static constexpr unsigned int MAX_GENPHO = 10; + /// Maximum number of generator level protons per event + static constexpr unsigned int MAX_GENPRO = 8; + /// Maximum number of jets per event + static constexpr unsigned int MAX_JETS = 40; + /// Maximum number of reconstructed local tracks in RPs + static constexpr unsigned int MAX_LOCALPCAND = 120; + /// Maximum number of reconstructed protons + static constexpr unsigned int MAX_PRO = 120; + + ////// Tree contents ////// + + // Run/event quantities + unsigned int BX, Run, LumiSection, EventNum; + float CrossingAngle; + //int LHCFillNum, LHCBeamMode; + //double AvgInstDelLumi, BunchInstLumi[3]; + + // HLT quantities + unsigned int nHLT; + int HLT_Accept[MAX_HLT], HLT_Prescl[MAX_HLT]; + std::vector* HLT_Name; + /*int nHLTLeptonCand[MAX_HLT]; + double HLTLeptonCand_pt[2][MAX_HLT]; + double HLTLeptonCand_eta[2][MAX_HLT]; + double HLTLeptonCand_phi[2][MAX_HLT]; + int HLTLeptonCand_charge[2][MAX_HLT]; + int HLT_LeadingLepton[MAX_HLT], HLT_TrailingLepton[MAX_HLT]; + int HLT_LeadingLepton_Prescl[MAX_HLT], HLT_TrailingLepton_Prescl[MAX_HLT];*/ + + // Generator level quantities + unsigned int nGenMuonCand, nGenMuonCandOutOfAccept; + double GenMuonCand_pt[MAX_GENMU], GenMuonCand_eta[MAX_GENMU], GenMuonCand_phi[MAX_GENMU], GenMuonCand_e[MAX_GENMU]; + unsigned int nGenEleCand, nGenEleCandOutOfAccept; + double GenEleCand_pt[MAX_GENELE], GenEleCand_eta[MAX_GENELE], GenEleCand_phi[MAX_GENELE], GenEleCand_e[MAX_GENELE]; + double GenPair_pt, GenPair_eta, GenPair_phi, GenPair_mass; + double GenPair_dphi, GenPair_dpt, GenPair_3Dangle; + unsigned int nGenPhotCand, nGenPhotCandOutOfAccept; + double GenPhotCand_pt[MAX_GENPHO], GenPhotCand_eta[MAX_GENPHO], GenPhotCand_phi[MAX_GENPHO], GenPhotCand_e[MAX_GENPHO]; + unsigned int nGenProtCand; + double GenProtCand_pt[MAX_GENPRO], GenProtCand_eta[MAX_GENPRO], GenProtCand_phi[MAX_GENPRO], GenProtCand_e[MAX_GENPHO]; + int GenProtCand_status[MAX_GENPRO]; + + // Pileup reweighting quantities + double PUWeightTrue, Weight; + + // Muon quantities + unsigned int nMuonCand; + double MuonCand_pt[MAX_LL], MuonCand_eta[MAX_LL], MuonCand_phi[MAX_LL], MuonCand_e[MAX_LL]; + double MuonCand_innerTrackPt[MAX_LL], MuonCand_innerTrackEta[MAX_LL], MuonCand_innerTrackPhi[MAX_LL]; + double MuonCand_innerTrackVtxz[MAX_LL]; + double MuonCand_vtxx[MAX_LL], MuonCand_vtxy[MAX_LL], MuonCand_vtxz[MAX_LL]; + int MuonCand_charge[MAX_LL]; + double MuonCand_dxy[MAX_LL]; + int MuonCand_nstatseg[MAX_LL], MuonCand_npxlhits[MAX_LL], MuonCand_ntrklayers[MAX_LL]; + int MuonCandTrack_nmuchits[MAX_LL]; + double MuonCandTrack_chisq[MAX_LL]; + int MuonCand_isglobal[MAX_LL], MuonCand_istracker[MAX_LL], MuonCand_isstandalone[MAX_LL], MuonCand_ispfmuon[MAX_LL]; + int MuonCand_istight[MAX_LL]; + + // Electron quantities + unsigned int nEleCand; + double EleCand_et[MAX_LL], EleCand_eta[MAX_LL], EleCand_phi[MAX_LL], EleCand_e[MAX_LL]; + double EleCand_vtxx[MAX_LL], EleCand_vtxy[MAX_LL], EleCand_vtxz[MAX_LL]; + double EleCand_innerTrackPt[MAX_LL], EleCand_innerTrackEta[MAX_LL], EleCand_innerTrackPhi[MAX_LL]; + double EleCand_innerTrackVtxz[MAX_LL]; + int EleCand_charge[MAX_LL]; + double EleCand_deltaPhi[MAX_LL], EleCand_deltaEta[MAX_LL]; + double EleCand_HoverE[MAX_LL]; + double EleCand_trackiso[MAX_LL], EleCand_ecaliso[MAX_LL], EleCand_hcaliso[MAX_LL]; + double EleCand_sigmaIetaIeta[MAX_LL]; + double EleCand_convDist[MAX_LL], EleCand_convDcot[MAX_LL]; + int EleCand_ecalDriven[MAX_LL]; + int EleCand_tightID[MAX_LL], EleCand_mediumID[MAX_LL]; + + // Photon quantities + unsigned int nPhotonCand; + double PhotonCand_pt[MAX_PHO], PhotonCand_eta[MAX_PHO], PhotonCand_phi[MAX_PHO], PhotonCand_e[MAX_PHO]; + double PhotonCand_r9[MAX_PHO]; + double PhotonCand_drtrue[MAX_PHO], PhotonCand_detatrue[MAX_PHO], PhotonCand_dphitrue[MAX_PHO]; + int PhotonCand_tightID[MAX_PHO], PhotonCand_mediumID[MAX_PHO]; + + // Pair quantities + unsigned int nPair; + int Pair_lepton1[MAX_PAIRS], Pair_lepton2[MAX_PAIRS]; + double Pair_pt[MAX_PAIRS], Pair_eta[MAX_PAIRS], Pair_phi[MAX_PAIRS], Pair_mass[MAX_PAIRS]; + double Pair_dpt[MAX_PAIRS], Pair_dphi[MAX_PAIRS], Pair_3Dangle[MAX_PAIRS]; + //double Pair_mindist[MAX_PAIRS]; + + unsigned int nPairGamma; + int PairGamma_pair[MAX_PHO]; + double PairGamma_mass[MAX_PHO]; + + // Extra tracks + unsigned int Pair_extratracks0p5mm[MAX_PAIRS]; + unsigned int Pair_extratracks1mm[MAX_PAIRS], Pair_extratracks2mm[MAX_PAIRS]; + unsigned int Pair_extratracks3mm[MAX_PAIRS], Pair_extratracks4mm[MAX_PAIRS]; + unsigned int Pair_extratracks5mm[MAX_PAIRS], Pair_extratracks1cm[MAX_PAIRS]; + unsigned int Pair_extratracks2cm[MAX_PAIRS], Pair_extratracks3cm[MAX_PAIRS]; + unsigned int Pair_extratracks4cm[MAX_PAIRS], Pair_extratracks5cm[MAX_PAIRS]; + unsigned int Pair_extratracks10cm[MAX_PAIRS]; + + // Vertex quantities + unsigned int nPrimVertexCand; + int PrimVertexCand_hasdil[MAX_VTX]; + double PrimVertexCand_x[MAX_VTX], PrimVertexCand_y[MAX_VTX], PrimVertexCand_z[MAX_VTX]; + unsigned int PrimVertexCand_tracks[MAX_VTX]; + double PrimVertexCand_chi2[MAX_VTX]; + unsigned int PrimVertexCand_ndof[MAX_VTX]; + double KalmanVertexCand_x[MAX_VTX], KalmanVertexCand_y[MAX_VTX], KalmanVertexCand_z[MAX_VTX]; + + // Extra tracks on vertex quantities + unsigned int nExtraTracks; + int ExtraTrack_pair[MAX_ET]; + int ExtraTrack_purity[MAX_ET]; + unsigned int ExtraTrack_nhits[MAX_ET]; + int ExtraTrack_charge[MAX_ET]; + unsigned int ExtraTrack_ndof[MAX_ET]; + double ExtraTrack_px[MAX_ET], ExtraTrack_py[MAX_ET], ExtraTrack_pz[MAX_ET]; + double ExtraTrack_chi2[MAX_ET]; + double ExtraTrack_vtxdxyz[MAX_ET]; + double ExtraTrack_vtxT[MAX_ET], ExtraTrack_vtxZ[MAX_ET]; + double ExtraTrack_x[MAX_ET], ExtraTrack_y[MAX_ET], ExtraTrack_z[MAX_ET]; + double ClosestExtraTrack_vtxdxyz[MAX_PAIRS], ClosestHighPurityExtraTrack_vtxdxyz[MAX_PAIRS]; + int ClosestExtraTrack_id[MAX_PAIRS], ClosestHighPurityExtraTrack_id[MAX_PAIRS]; + unsigned int nQualityExtraTrack; + + // Jets/MET quantities + unsigned int nJetCand; + double JetCand_pt[MAX_JETS], JetCand_eta[MAX_JETS], JetCand_phi[MAX_JETS], JetCand_e[MAX_JETS]; + double HighestJet_pt, HighestJet_eta, HighestJet_phi, HighestJet_e; + double SumJet_e; + double Etmiss, Etmiss_phi, Etmiss_significance; + + // CTPPS quantities + unsigned int nLocalProtCand; + double LocalProtCand_x[MAX_LOCALPCAND], LocalProtCand_y[MAX_LOCALPCAND], LocalProtCand_t[MAX_LOCALPCAND]; + double LocalProtCand_xSigma[MAX_LOCALPCAND], LocalProtCand_ySigma[MAX_LOCALPCAND], LocalProtCand_tSigma[MAX_LOCALPCAND]; + int LocalProtCand_arm[MAX_LOCALPCAND], LocalProtCand_station[MAX_LOCALPCAND], LocalProtCand_pot[MAX_LOCALPCAND], LocalProtCand_rpid[MAX_LOCALPCAND]; + + // reco proton quantities + unsigned int nRecoProtCand; + double ProtCand_xi[MAX_PRO], ProtCand_t[MAX_PRO], ProtCand_ThX[MAX_PRO], ProtCand_ThY[MAX_PRO]; + int ProtCand_rpid[MAX_PRO], ProtCand_arm[MAX_PRO], ProtCand_ismultirp[MAX_PRO]; + + void clear() { + // event-level branches + BX = Run = LumiSection = EventNum = 0; + CrossingAngle = 0.0; + + // high-level trigger + nHLT = 0; + for ( unsigned int i = 0; i < MAX_HLT; ++i ) { + HLT_Accept[i] = HLT_Prescl[i] = -1; + } + + // gen-level information + nGenMuonCand = nGenMuonCandOutOfAccept = 0; + for ( unsigned int i = 0; i < MAX_GENMU; ++i ) { + GenMuonCand_pt[i] = GenMuonCand_eta[i] = GenMuonCand_phi[i] = GenMuonCand_e[i] = -999.; + } + nGenEleCand = nGenEleCandOutOfAccept = 0; + for ( unsigned int i = 0; i < MAX_GENELE; ++i ) { + GenEleCand_pt[i] = GenEleCand_eta[i] = GenEleCand_phi[i] = GenEleCand_e[i] = -999.; + } + GenPair_pt = GenPair_eta = GenPair_phi = GenPair_mass = -999.; + GenPair_dphi = GenPair_dpt = GenPair_3Dangle = -999.; + nGenPhotCand = nGenPhotCandOutOfAccept = 0; + for ( unsigned int i = 0; i < MAX_GENPHO; ++i ) { + GenPhotCand_pt[i] = GenPhotCand_eta[i] = GenPhotCand_phi[i] = GenPhotCand_e[i] = -999.; + } + nGenProtCand = 0; + for ( unsigned int i = 0; i < MAX_GENPRO; ++i ) { + GenProtCand_pt[i] = GenProtCand_eta[i] = GenProtCand_phi[i] = GenProtCand_e[i] = -999.; + GenProtCand_status[i] = -1; + } + + PUWeightTrue = Weight = 0.; + + //LHCFillNum = LHCBeamMode = -1; + + // single lepton candidates + nMuonCand = nEleCand = 0; + for ( unsigned int i = 0; i < MAX_LL; ++i ) { + MuonCand_pt[i] = MuonCand_eta[i] = MuonCand_phi[i] = MuonCand_e[i] = -999.; + MuonCand_innerTrackPt[i] = MuonCand_innerTrackEta[i] = MuonCand_innerTrackPhi[i] = -999.; + MuonCand_innerTrackVtxz[i] = -999.; + MuonCand_vtxx[i] = MuonCand_vtxy[i] = MuonCand_vtxz[i] = -999.; + MuonCand_charge[i] = 0; + MuonCand_dxy[i] = -999.; + MuonCand_nstatseg[i] = MuonCand_npxlhits[i] = MuonCand_ntrklayers[i] = -999; + MuonCandTrack_nmuchits[i] = -999; + MuonCandTrack_chisq[i] = -999.; + MuonCand_isglobal[i] = MuonCand_istracker[i] = MuonCand_isstandalone[i] = MuonCand_ispfmuon[i] = -999; + MuonCand_istight[i] = -999; + EleCand_et[i] = EleCand_eta[i] = EleCand_phi[i] = EleCand_e[i] = -999.; + EleCand_vtxx[i] = EleCand_vtxy[i] = EleCand_vtxz[i] = -999.; + EleCand_innerTrackPt[i] = EleCand_innerTrackEta[i] = EleCand_innerTrackPhi[i] = -999.; + EleCand_innerTrackVtxz[i] = -999.; + EleCand_charge[i] = 0; + EleCand_deltaPhi[i] = EleCand_deltaEta[i] = -999.; + EleCand_HoverE[i] = -999.; + EleCand_trackiso[i] = EleCand_ecaliso[i] = EleCand_hcaliso[i] = -999.; + EleCand_sigmaIetaIeta[i] = -999.; + EleCand_convDist[i] = EleCand_convDcot[i] = -999.; + EleCand_ecalDriven[i] = -999; + EleCand_tightID[i] = EleCand_mediumID[i] = -1; + } + + // single photon candidates + nPhotonCand = 0; + for ( unsigned int i = 0; i < MAX_PHO; ++i ) { + PhotonCand_pt[i] = PhotonCand_eta[i] = PhotonCand_phi[i] = PhotonCand_e[i] = -999.; + PhotonCand_r9[i] = -999.; + PhotonCand_drtrue[i] = PhotonCand_detatrue[i] = PhotonCand_dphitrue[i] = -999.; + PhotonCand_tightID[i] = PhotonCand_mediumID[i] = -1; + } + + // dilepton pair candidates + nPair = 0; + for ( unsigned int i = 0; i < MAX_PAIRS; ++i ) { + Pair_lepton1[i] = Pair_lepton2[i] = -1; + Pair_pt[i] = Pair_mass[i] = Pair_phi[i] = Pair_eta[i] = -999.; + Pair_dpt[i] = Pair_dphi[i] = Pair_3Dangle[i] = -999.; + //Pair_mindist[i] = -999.; + } + + // dilepton pair + associated photon candidates + nPairGamma = 0; + for ( unsigned int i = 0; i < MAX_PHO; ++i ) { + PairGamma_pair[i] = -1; + PairGamma_mass[i] = -999.; + } + + // extra tracks associated to the central system vertex + for ( unsigned int i = 0; i < MAX_PAIRS; ++i ) { + Pair_extratracks0p5mm[i] = 0; + Pair_extratracks1mm[i] = Pair_extratracks2mm[i] = Pair_extratracks3mm[i] = 0; + Pair_extratracks4mm[i] = Pair_extratracks5mm[i] = Pair_extratracks1cm[i] = 0; + Pair_extratracks2cm[i] = Pair_extratracks3cm[i] = Pair_extratracks4cm[i] = 0; + Pair_extratracks5cm[i] = Pair_extratracks10cm[i] = 0; + } + + // offline primary vertices + nPrimVertexCand = 0; + for ( unsigned int i = 0; i < MAX_VTX; ++i ) { + PrimVertexCand_hasdil[i] = -1; + PrimVertexCand_x[i] = PrimVertexCand_y[i] = PrimVertexCand_z[i] = -999.; + PrimVertexCand_tracks[i] = 0; + PrimVertexCand_chi2[i] = -999.; + PrimVertexCand_ndof[i] = 0; + KalmanVertexCand_x[i] = KalmanVertexCand_y[i] = KalmanVertexCand_z[i] = -999.; + } + + // extra tracks associated to the central system + nExtraTracks = 0; + for ( unsigned int i = 0; i < MAX_ET; ++i ) { + ExtraTrack_pair[i] = -1; + ExtraTrack_purity[i] = ExtraTrack_nhits[i] = -1; + ExtraTrack_charge[i] = -999; + ExtraTrack_ndof[i] = 0; + ExtraTrack_px[i] = ExtraTrack_py[i] = ExtraTrack_pz[i] = -999.; + ExtraTrack_chi2[i] = ExtraTrack_vtxdxyz[i] = -999.; + ExtraTrack_vtxT[i] = ExtraTrack_vtxZ[i] = -999.; + ExtraTrack_x[i] = ExtraTrack_y[i] = ExtraTrack_z[i] = -999.; + } + for ( unsigned int i = 0; i < MAX_PAIRS; ++i ) { + ClosestExtraTrack_vtxdxyz[i] = ClosestHighPurityExtraTrack_vtxdxyz[i] = -999.; + ClosestExtraTrack_id[i] = ClosestHighPurityExtraTrack_id[i] = -1; + } + nQualityExtraTrack = 0; + + // jets collection + nJetCand = 0; + for ( unsigned int i = 0; i < MAX_JETS; ++i ) { + JetCand_pt[i] = JetCand_eta[i] = JetCand_phi[i] = JetCand_e[i] = -999; + } + HighestJet_pt = HighestJet_eta = HighestJet_phi = HighestJet_e = -999.; + SumJet_e = 0.; + + // missing ET + Etmiss = Etmiss_phi = Etmiss_significance = -999.; + + // CTPPS strips leaves + nLocalProtCand = 0; + for ( unsigned int i = 0; i < MAX_LOCALPCAND; ++i ) { + LocalProtCand_x[i] = LocalProtCand_y[i] = LocalProtCand_t[i] = -999.; + LocalProtCand_xSigma[i] = LocalProtCand_ySigma[i] = LocalProtCand_tSigma[i] = -999.; + LocalProtCand_arm[i] = LocalProtCand_station[i] = LocalProtCand_pot[i] = LocalProtCand_rpid[i] = -1; + } + + nRecoProtCand = 0; + for (unsigned int i = 0; i < MAX_PRO; ++i ) + { + ProtCand_xi[i] = -999.; + ProtCand_t[i] = -999.; + ProtCand_ThX[i] = -999.; + ProtCand_ThY[i] = -999.; + ProtCand_rpid[i] = -1; + ProtCand_arm[i] = -1; + ProtCand_ismultirp[i] = -1; + + } + } + void attach( TTree* tree, TreeType tt, bool mc, bool storetracks ) { + if ( !tree ) return; + + tree->Branch( "Run", &Run, "Run/i" ); + tree->Branch( "LumiSection", &LumiSection, "LumiSection/i" ); + tree->Branch( "BX", &BX, "BX/i" ); + tree->Branch( "EventNum", &EventNum, "EventNum/i" ); + tree->Branch( "CrossingAngle", &CrossingAngle, "CrossingAngle/F"); + + tree->Branch( "nHLT", &nHLT, "nHLT/i" ); + tree->Branch( "HLT_Accept", HLT_Accept, "HLT_Accept[nHLT]/I" ); + tree->Branch( "HLT_Prescl", HLT_Prescl, "HLT_Prescl[nHLT]/I" ); + tree->Branch( "HLT_Name", &HLT_Name); + + if ( tt == ElectronMuon || tt == DiMuon ) { + tree->Branch( "nMuonCand", &nMuonCand, "nMuonCand/i" ); + tree->Branch( "MuonCand_pt", MuonCand_pt, "MuonCand_pt[nMuonCand]/D" ); + tree->Branch( "MuonCand_eta", MuonCand_eta, "MuonCand_eta[nMuonCand]/D" ); + tree->Branch( "MuonCand_phi", MuonCand_phi, "MuonCand_phi[nMuonCand]/D" ); + tree->Branch( "MuonCand_e", MuonCand_e, "MuonCand_e[nMuonCand]/D" ); + tree->Branch( "MuonCand_charge", MuonCand_charge, "MuonCand_charge[nMuonCand]/I" ); + tree->Branch( "MuonCand_vtxx", MuonCand_vtxx, "MuonCand_vtxx[nMuonCand]/D" ); + tree->Branch( "MuonCand_vtxy", MuonCand_vtxy, "MuonCand_vtxy[nMuonCand]/D" ); + tree->Branch( "MuonCand_vtxz", MuonCand_vtxz, "MuonCand_vtxz[nMuonCand]/D" ); + tree->Branch( "MuonCand_dxy", MuonCand_dxy, "MuonCand_dxy[nMuonCand]/D" ); + tree->Branch( "MuonCand_nstatseg", MuonCand_nstatseg, "MuonCand_nstatseg[nMuonCand]/I" ); + tree->Branch( "MuonCand_ntrklayers", MuonCand_ntrklayers, "MuonCand_ntrklayers[nMuonCand]/I" ); + tree->Branch( "MuonCand_npxlhits", MuonCand_npxlhits, "MuonCand_npxlhits[nMuonCand]/I" ); + tree->Branch( "MuonCand_isglobal", MuonCand_isglobal, "MuonCand_isglobal[nMuonCand]/I" ); + tree->Branch( "MuonCand_istracker", MuonCand_istracker, "MuonCand_istracker[nMuonCand]/I" ); + tree->Branch( "MuonCand_isstandalone", MuonCand_isstandalone, "MuonCand_isstandalone[nMuonCand]/I" ); + tree->Branch( "MuonCand_ispfmuon", MuonCand_ispfmuon, "MuonCand_ispfmuon[nMuonCand]/I" ); + tree->Branch( "MuonCand_istight", MuonCand_istight, "MuonCand_istight[nMuonCand]/I" ); + tree->Branch( "MuonCandTrack_nmuchits", MuonCandTrack_nmuchits, "MuonCandTrack_nmuchits[nMuonCand]/I" ); + tree->Branch( "MuonCandTrack_chisq", MuonCandTrack_chisq, "MuonCandTrack_chisq[nMuonCand]/D" ); + tree->Branch( "MuonCand_innerTrackPt", MuonCand_innerTrackPt, "MuonCand_innerTrackPt[nMuonCand]/D" ); + tree->Branch( "MuonCand_innerTrackEta", MuonCand_innerTrackEta, "MuonCand_innerTrackEta[nMuonCand]/D" ); + tree->Branch( "MuonCand_innerTrackPhi", MuonCand_innerTrackPhi, "MuonCand_innerTrackPhi[nMuonCand]/D" ); + tree->Branch( "MuonCand_innerTrackVtxz", MuonCand_innerTrackVtxz, "MuonCand_innerTrackVtxz[nMuonCand]/D" ); + if ( mc ) { + tree->Branch( "nGenMuonCand", &nGenMuonCand, "nGenMuonCand/i" ); + tree->Branch( "nGenMuonCandOutOfAccept", &nGenMuonCandOutOfAccept, "nGenMuonCandOutOfAccept/i" ); + tree->Branch( "GenMuonCand_pt", GenMuonCand_pt, "GenMuonCand_pt[nGenMuonCand]/D" ); + tree->Branch( "GenMuonCand_eta", GenMuonCand_eta, "GenMuonCand_eta[nGenMuonCand]/D" ); + tree->Branch( "GenMuonCand_phi", GenMuonCand_phi, "GenMuonCand_phi[nGenMuonCand]/D" ); + tree->Branch( "GenMuonCand_e", GenMuonCand_e, "GenMuonCand_e[nGenMuonCand]/D" ); + } + } + + if ( tt == ElectronMuon || tt == DiElectron ) { + tree->Branch( "nEleCand", &nEleCand, "nEleCand/i" ); + tree->Branch( "EleCand_et", EleCand_et, "EleCand_et[nEleCand]/D" ); + tree->Branch( "EleCand_eta", EleCand_eta, "EleCand_eta[nEleCand]/D" ); + tree->Branch( "EleCand_phi", EleCand_phi, "EleCand_phi[nEleCand]/D" ); + tree->Branch( "EleCand_e", EleCand_e, "EleCand_e[nEleCand]/D" ); + tree->Branch( "EleCand_charge", EleCand_charge, "EleCand_charge[nEleCand]/I" ); + tree->Branch( "EleCand_vtxx", EleCand_vtxx, "EleCand_vtxx[nEleCand]/D" ); + tree->Branch( "EleCand_vtxy", EleCand_vtxy, "EleCand_vtxy[nEleCand]/D" ); + tree->Branch( "EleCand_vtxz", EleCand_vtxz, "EleCand_vtxz[nEleCand]/D" ); + tree->Branch( "EleCand_deltaPhi", EleCand_deltaPhi, "EleCand_deltaPhi[nEleCand]/D" ); + tree->Branch( "EleCand_deltaEta", EleCand_deltaEta, "EleCand_deltaEta[nEleCand]/D" ); + tree->Branch( "EleCand_HoverE", EleCand_HoverE, "EleCand_HoverE[nEleCand]/D" ); + tree->Branch( "EleCand_trackiso", EleCand_trackiso, "EleCand_trackiso[nEleCand]/D" ); + tree->Branch( "EleCand_ecaliso", EleCand_ecaliso," EleCand_ecaliso[nEleCand]/D" ); + tree->Branch( "EleCand_hcaliso", EleCand_hcaliso," EleCand_hcaliso[nEleCand]/D" ); + tree->Branch( "EleCand_sigmaIetaIeta", EleCand_sigmaIetaIeta, "EleCand_sigmaIetaIeta[nEleCand]/D" ); + tree->Branch( "EleCand_convDist", EleCand_convDist, "EleCand_convDist[nEleCand]/D" ); + tree->Branch( "EleCand_convDcot", EleCand_convDcot, "EleCand_convDcot[nEleCand]/D" ); + tree->Branch( "EleCand_ecalDriven", EleCand_ecalDriven, "EleCand_ecalDriven[nEleCand]/D" ); + tree->Branch( "EleCand_mediumID", EleCand_mediumID, "EleCand_mediumID[nEleCand]/I" ); + tree->Branch( "EleCand_tightID", EleCand_tightID, "EleCand_tightID[nEleCand]/I" ); + tree->Branch( "EleCand_innerTrackPt", EleCand_innerTrackPt, "EleCand_innerTrackPt[nEleCand]/D" ); + tree->Branch( "EleCand_innerTrackEta", EleCand_innerTrackEta, "EleCand_innerTrackEta[nEleCand]/D" ); + tree->Branch( "EleCand_innerTrackPhi", EleCand_innerTrackPhi, "EleCand_innerTrackPhi[nEleCand]/D" ); + tree->Branch( "EleCand_innerTrackVtxz", EleCand_innerTrackVtxz, "EleCand_innerTrackVtxz[nEleCand]/D" ); + if ( mc ) { + tree->Branch( "nGenEleCand", &nGenEleCand, "nGenEleCand/i" ); + tree->Branch( "nGenEleCandOutOfAccept", &nGenEleCandOutOfAccept, "nGenEleCandOutOfAccept/I" ); + tree->Branch( "GenEleCand_pt", GenEleCand_pt, "GenEleCand_pt[nGenEleCand]/D" ); + tree->Branch( "GenEleCand_eta", GenEleCand_eta, "GenEleCand_eta[nGenEleCand]/D" ); + tree->Branch( "GenEleCand_phi", GenEleCand_phi, "GenEleCand_phi[nGenEleCand]/D" ); + tree->Branch( "GenEleCand_e", GenEleCand_e, "GenEleCand_e[nGenEleCand]/D" ); + } + } + if ( mc ) { + tree->Branch( "nGenProtCand", &nGenProtCand, "nGenProtCand/i" ); + tree->Branch( "GenProtCand_pt", GenProtCand_pt, "GenProtCand_pt[nGenProtCand]/D" ); + tree->Branch( "GenProtCand_eta", GenProtCand_eta, "GenProtCand_eta[nGenProtCand]/D" ); + tree->Branch( "GenProtCand_phi", GenProtCand_phi, "GenProtCand_phi[nGenProtCand]/D" ); + tree->Branch( "GenProtCand_e", GenProtCand_e, "GenProtCand_e[nGenProtCand]/D" ); + tree->Branch( "GenProtCand_status", GenProtCand_status, "GenProtCand_status[nGenProtCand]/I" ); + } + + // Primary vertices' information + tree->Branch( "nPrimVertexCand", &nPrimVertexCand, "nPrimVertexCand/i" ); + tree->Branch( "PrimVertexCand_x", PrimVertexCand_x, "PrimVertexCand_x[nPrimVertexCand]/D" ); + tree->Branch( "PrimVertexCand_y", PrimVertexCand_y, "PrimVertexCand_y[nPrimVertexCand]/D" ); + tree->Branch( "PrimVertexCand_z", PrimVertexCand_z, "PrimVertexCand_z[nPrimVertexCand]/D" ); + tree->Branch( "PrimVertexCand_chi2", PrimVertexCand_chi2, "PrimVertexCand_chi2[nPrimVertexCand]/D" ); + tree->Branch( "PrimVertexCand_ndof", PrimVertexCand_ndof, "PrimVertexCand_ndof[nPrimVertexCand]/i" ); + tree->Branch( "PrimVertexCand_tracks", PrimVertexCand_tracks, "PrimVertexCand_tracks[nPrimVertexCand]/i" ); + + // Lepton pairs' information + tree->Branch( "nPair", &nPair, "nPair/i" ); + tree->Branch( "Pair_lepton1", Pair_lepton1, "Pair_lepton1[nPair]/I" ); + tree->Branch( "Pair_lepton2", Pair_lepton2, "Pair_lepton2[nPair]/I" ); + //tree->Branch( "Pair_mindist", Pair_mindist, "Pair_mindist[nPair]/D" ); + tree->Branch( "Pair_mass", Pair_mass, "Pair_mass[nPair]/D" ); + tree->Branch( "Pair_pt", Pair_pt, "Pair_pt[nPair]/D" ); + tree->Branch( "Pair_eta", Pair_eta, "Pair_eta[nPair]/D" ); + tree->Branch( "Pair_phi", Pair_phi, "Pair_phi[nPair]/D" ); + tree->Branch( "Pair_dpt", Pair_dpt, "Pair_dpt[nPair]/D" ); + tree->Branch( "Pair_dphi", Pair_dphi, "Pair_dphi[nPair]/D" ); + tree->Branch( "Pair_3Dangle", Pair_3Dangle, "Pair_3Dangle[nPair]/D" ); + tree->Branch( "Pair_extratracks0p5mm", Pair_extratracks0p5mm, "Pair_extratracks0p5mm[nPair]/i" ); + tree->Branch( "Pair_extratracks1mm", Pair_extratracks1mm, "Pair_extratracks1mm[nPair]/i" ); + tree->Branch( "Pair_extratracks2mm", Pair_extratracks2mm, "Pair_extratracks2mm[nPair]/i" ); + tree->Branch( "Pair_extratracks3mm", Pair_extratracks3mm, "Pair_extratracks3mm[nPair]/i" ); + tree->Branch( "Pair_extratracks4mm", Pair_extratracks4mm, "Pair_extratracks4mm[nPair]/i" ); + tree->Branch( "Pair_extratracks5mm", Pair_extratracks5mm, "Pair_extratracks5mm[nPair]/i" ); + tree->Branch( "Pair_extratracks1cm", Pair_extratracks1cm, "Pair_extratracks1cm[nPair]/i" ); + tree->Branch( "Pair_extratracks2cm", Pair_extratracks2cm, "Pair_extratracks2cm[nPair]/i" ); + tree->Branch( "Pair_extratracks3cm", Pair_extratracks3cm, "Pair_extratracks3cm[nPair]/i" ); + tree->Branch( "Pair_extratracks4cm", Pair_extratracks4cm, "Pair_extratracks4cm[nPair]/i" ); + tree->Branch( "Pair_extratracks5cm", Pair_extratracks5cm, "Pair_extratracks5cm[nPair]/i" ); + tree->Branch( "Pair_extratracks10cm", Pair_extratracks10cm, "Pair_extratracks10cm[nPair]/i" ); + // Kalman dilepton vertex information + tree->Branch( "KalmanVertexCand_x", KalmanVertexCand_x, "KalmanVertexCand_x[nPair]/D" ); + tree->Branch( "KalmanVertexCand_y", KalmanVertexCand_y, "KalmanVertexCand_y[nPair]/D" ); + tree->Branch( "KalmanVertexCand_z", KalmanVertexCand_z, "KalmanVertexCand_z[nPair]/D" ); + + if ( mc ) { + tree->Branch( "GenPair_mass", &GenPair_mass, "GenPair_mass/D" ); + tree->Branch( "GenPair_pt", &GenPair_pt, "GenPair_pt/D" ); + tree->Branch( "GenPair_eta", &GenPair_eta, "GenPair_eta/D" ); + tree->Branch( "GenPair_phi", &GenPair_phi, "GenPair_phi/D" ); + tree->Branch( "GenPair_dpt", &GenPair_dpt, "GenPair_dpt/D" ); + tree->Branch( "GenPair_dphi", &GenPair_dphi, "GenPair_dphi/D" ); + tree->Branch( "GenPair_3Dangle", &GenPair_3Dangle, "GenPair_3Dangle/D" ); + } + + // if ( !mc ) { + if(1) { + tree->Branch( "nLocalProtCand", &nLocalProtCand, "nLocalProtCand/i" ); + tree->Branch( "LocalProtCand_x", LocalProtCand_x, "LocalProtCand_x[nLocalProtCand]/D" ); + tree->Branch( "LocalProtCand_y", LocalProtCand_y, "LocalProtCand_y[nLocalProtCand]/D" ); + tree->Branch( "LocalProtCand_t", LocalProtCand_t, "LocalProtCand_t[nLocalProtCand]/D" ); + tree->Branch( "LocalProtCand_xSigma", LocalProtCand_xSigma, "LocalProtCand_xSigma[nLocalProtCand]/D" ); + tree->Branch( "LocalProtCand_ySigma", LocalProtCand_ySigma, "LocalProtCand_ySigma[nLocalProtCand]/D" ); + tree->Branch( "LocalProtCand_tSigma", LocalProtCand_tSigma, "LocalProtCand_tSigma[nLocalProtCand]/D" ); + tree->Branch( "LocalProtCand_arm", LocalProtCand_arm, "LocalProtCand_arm[nLocalProtCand]/I" ); + tree->Branch( "LocalProtCand_station", LocalProtCand_station, "LocalProtCand_station[nLocalProtCand]/I" ); + tree->Branch( "LocalProtCand_pot", LocalProtCand_pot, "LocalProtCand_pot[nLocalProtCand]/I" ); + tree->Branch( "LocalProtCand_rpid", LocalProtCand_rpid, "LocalProtCand_rpid[nLocalProtCand]/I" ); + + tree->Branch( "nRecoProtCand", &nRecoProtCand, "nRecoProtCand/i" ); + tree->Branch( "ProtCand_xi", ProtCand_xi, "ProtCand_xi[nRecoProtCand]/D" ); + tree->Branch( "ProtCand_t", ProtCand_t, "ProtCand_t[nRecoProtCand]/D" ); + tree->Branch( "ProtCand_ThX", ProtCand_ThX, "ProtCand_ThX[nRecoProtCand]/D" ); + tree->Branch( "ProtCand_ThY", ProtCand_ThY, "ProtCand_ThY[nRecoProtCand]/D" ); + tree->Branch( "ProtCand_rpid", ProtCand_rpid, "ProtCand_rpid[nRecoProtCand]/I" ); + tree->Branch( "ProtCand_arm", ProtCand_arm, "ProtCand_arm[nRecoProtCand]/I" ); + tree->Branch( "ProtCand_ismultirp", ProtCand_ismultirp, "ProtCand_ismultirp[nRecoProtCand]/I" ); + + } + + // Extra tracks on vertex's information + if(storetracks == true) + { + tree->Branch( "nExtraTracks", &nExtraTracks, "nExtraTracks/i" ); + tree->Branch( "ExtraTrack_pair", ExtraTrack_pair, "ExtraTrack_pair[nExtraTracks]/I" ); + tree->Branch( "ExtraTrack_purity", ExtraTrack_purity, "ExtraTrack_purity[nExtraTracks]/I" ); + tree->Branch( "ExtraTrack_nhits", ExtraTrack_nhits, "ExtraTrack_nhits[nExtraTracks]/i" ); + tree->Branch( "ExtraTrack_charge", ExtraTrack_charge, "ExtraTrack_charge[nExtraTracks]/I" ); + tree->Branch( "ExtraTrack_ndof", ExtraTrack_ndof, "ExtraTrack_ndof[nExtraTracks]/i" ); + tree->Branch( "ExtraTrack_px", ExtraTrack_px, "ExtraTrack_px[nExtraTracks]/D" ); + tree->Branch( "ExtraTrack_py", ExtraTrack_py, "ExtraTrack_py[nExtraTracks]/D" ); + tree->Branch( "ExtraTrack_pz", ExtraTrack_pz, "ExtraTrack_pz[nExtraTracks]/D" ); + tree->Branch( "ExtraTrack_chi2", ExtraTrack_chi2, "ExtraTrack_chi2[nExtraTracks]/D" ); + tree->Branch( "ExtraTrack_vtxdxyz", ExtraTrack_vtxdxyz, "ExtraTrack_vtxdxyz[nExtraTracks]/D" ); + tree->Branch( "ExtraTrack_vtxT", ExtraTrack_vtxT, "ExtraTrack_vtxT[nExtraTracks]/D" ); + tree->Branch( "ExtraTrack_vtxZ", ExtraTrack_vtxZ, "ExtraTrack_vtxZ[nExtraTracks]/D" ); + tree->Branch( "ExtraTrack_x", ExtraTrack_x, "ExtraTrack_x[nExtraTracks]/D" ); + tree->Branch( "ExtraTrack_y", ExtraTrack_y, "ExtraTrack_y[nExtraTracks]/D" ); + tree->Branch( "ExtraTrack_z", ExtraTrack_z, "ExtraTrack_z[nExtraTracks]/D" ); + } + tree->Branch( "nQualityExtraTrack", &nQualityExtraTrack, "nQualityExtraTrack/i" ); + tree->Branch( "ClosestExtraTrack_vtxdxyz", ClosestExtraTrack_vtxdxyz, "ClosestExtraTrack_vtxdxyz[nPair]/D" ); + tree->Branch( "ClosestExtraTrack_id", ClosestExtraTrack_id, "ClosestExtraTrack_id[nPair]/I" ); + tree->Branch( "ClosestHighPurityExtraTrack_vtxdxyz", ClosestHighPurityExtraTrack_vtxdxyz, "ClosestHighPurityExtraTrack_vtxdxyz[nPair]/D" ); + tree->Branch( "ClosestHighPurityExtraTrack_id", ClosestHighPurityExtraTrack_id, "ClosestHighPurityExtraTrack_id[nPair]/I" ); + + // Jets/MET information + + // Pileup reweighting + tree->Branch( "Weight", &Weight, "Weight/D" ); + tree->Branch( "PUWeightTrue", &PUWeightTrue, "PUWeightTrue/D" ); + } + void load( TTree* tree, TreeType tt, bool mc, bool storetracks ) { + if ( !tree ) return; + + tree->SetBranchAddress( "Run", &Run ); + tree->SetBranchAddress( "LumiSection", &LumiSection ); + tree->SetBranchAddress( "BX", &BX ); + tree->SetBranchAddress( "EventNum", &EventNum ); + tree->SetBranchAddress( "CrossingAngle", &CrossingAngle ); + + tree->SetBranchAddress( "nHLT", &nHLT ); + tree->SetBranchAddress( "HLT_Accept", HLT_Accept ); + tree->SetBranchAddress( "HLT_Prescl", HLT_Prescl ); + tree->SetBranchAddress( "HLT_Name", &HLT_Name ); + + if ( tt == ElectronMuon || tt == DiMuon ) { + tree->SetBranchAddress( "nMuonCand", &nMuonCand ); + tree->SetBranchAddress( "MuonCand_pt", MuonCand_pt ); + tree->SetBranchAddress( "MuonCand_eta", MuonCand_eta ); + tree->SetBranchAddress( "MuonCand_phi", MuonCand_phi ); + tree->SetBranchAddress( "MuonCand_e", MuonCand_e ); + tree->SetBranchAddress( "MuonCand_charge", MuonCand_charge ); + tree->SetBranchAddress( "MuonCand_vtxx", MuonCand_vtxx ); + tree->SetBranchAddress( "MuonCand_vtxy", MuonCand_vtxy ); + tree->SetBranchAddress( "MuonCand_vtxz", MuonCand_vtxz ); + tree->SetBranchAddress( "MuonCand_dxy", MuonCand_dxy ); + tree->SetBranchAddress( "MuonCand_nstatseg", MuonCand_nstatseg ); + tree->SetBranchAddress( "MuonCand_ntrklayers", MuonCand_ntrklayers ); + tree->SetBranchAddress( "MuonCand_npxlhits", MuonCand_npxlhits ); + tree->SetBranchAddress( "MuonCand_isglobal", MuonCand_isglobal ); + tree->SetBranchAddress( "MuonCand_istracker", MuonCand_istracker ); + tree->SetBranchAddress( "MuonCand_isstandalone", MuonCand_isstandalone ); + tree->SetBranchAddress( "MuonCand_ispfmuon", MuonCand_ispfmuon ); + tree->SetBranchAddress( "MuonCand_istight", MuonCand_istight ); + tree->SetBranchAddress( "MuonCandTrack_nmuchits", MuonCandTrack_nmuchits ); + tree->SetBranchAddress( "MuonCandTrack_chisq", MuonCandTrack_chisq ); + tree->SetBranchAddress( "MuonCand_innerTrackPt", MuonCand_innerTrackPt ); + tree->SetBranchAddress( "MuonCand_innerTrackEta", MuonCand_innerTrackEta ); + tree->SetBranchAddress( "MuonCand_innerTrackPhi", MuonCand_innerTrackPhi ); + tree->SetBranchAddress( "MuonCand_innerTrackVtxz", MuonCand_innerTrackVtxz ); + if ( mc ) { + tree->SetBranchAddress( "nGenMuonCand", &nGenMuonCand ); + tree->SetBranchAddress( "nGenMuonCandOutOfAccept", &nGenMuonCandOutOfAccept ); + tree->SetBranchAddress( "GenMuonCand_pt", GenMuonCand_pt ); + tree->SetBranchAddress( "GenMuonCand_eta", GenMuonCand_eta ); + tree->SetBranchAddress( "GenMuonCand_phi", GenMuonCand_phi ); + tree->SetBranchAddress( "GenMuonCand_e", GenMuonCand_e ); + } + } + + if ( tt == ElectronMuon || tt == DiElectron ) { + tree->SetBranchAddress( "nEleCand", &nEleCand ); + tree->SetBranchAddress( "EleCand_et", EleCand_et ); + tree->SetBranchAddress( "EleCand_eta", EleCand_eta ); + tree->SetBranchAddress( "EleCand_phi", EleCand_phi ); + tree->SetBranchAddress( "EleCand_e", EleCand_e ); + tree->SetBranchAddress( "EleCand_charge", EleCand_charge ); + tree->SetBranchAddress( "EleCand_vtxx", EleCand_vtxx ); + tree->SetBranchAddress( "EleCand_vtxy", EleCand_vtxy ); + tree->SetBranchAddress( "EleCand_vtxz", EleCand_vtxz ); + tree->SetBranchAddress( "EleCand_deltaPhi", EleCand_deltaPhi ); + tree->SetBranchAddress( "EleCand_deltaEta", EleCand_deltaEta ); + tree->SetBranchAddress( "EleCand_HoverE", EleCand_HoverE ); + tree->SetBranchAddress( "EleCand_trackiso", EleCand_trackiso ); + tree->SetBranchAddress( "EleCand_ecaliso", EleCand_ecaliso ); + tree->SetBranchAddress( "EleCand_hcaliso", EleCand_hcaliso ); + tree->SetBranchAddress( "EleCand_sigmaIetaIeta", EleCand_sigmaIetaIeta ); + tree->SetBranchAddress( "EleCand_convDist", EleCand_convDist ); + tree->SetBranchAddress( "EleCand_convDcot", EleCand_convDcot ); + tree->SetBranchAddress( "EleCand_ecalDriven", EleCand_ecalDriven ); + tree->SetBranchAddress( "EleCand_mediumID", EleCand_mediumID ); + tree->SetBranchAddress( "EleCand_tightID", EleCand_tightID ); + tree->SetBranchAddress( "EleCand_innerTrackPt", EleCand_innerTrackPt ); + tree->SetBranchAddress( "EleCand_innerTrackEta", EleCand_innerTrackEta ); + tree->SetBranchAddress( "EleCand_innerTrackPhi", EleCand_innerTrackPhi ); + tree->SetBranchAddress( "EleCand_innerTrackVtxz", EleCand_innerTrackVtxz ); + if ( mc ) { + tree->SetBranchAddress( "nGenEleCand", &nGenEleCand ); + tree->SetBranchAddress( "nGenEleCandOutOfAccept", &nGenEleCandOutOfAccept ); + tree->SetBranchAddress( "GenEleCand_pt", GenEleCand_pt ); + tree->SetBranchAddress( "GenEleCand_eta", GenEleCand_eta ); + tree->SetBranchAddress( "GenEleCand_phi", GenEleCand_phi ); + tree->SetBranchAddress( "GenEleCand_e", GenEleCand_e ); + } + } + + if ( mc ) { + tree->SetBranchAddress( "nGenProtCand", &nGenProtCand ); + tree->SetBranchAddress( "GenProtCand_pt", GenProtCand_pt ); + tree->SetBranchAddress( "GenProtCand_eta", GenProtCand_eta ); + tree->SetBranchAddress( "GenProtCand_phi", GenProtCand_phi ); + tree->SetBranchAddress( "GenProtCand_e", GenProtCand_e ); + tree->SetBranchAddress( "GenProtCand_status", GenProtCand_status ); + } + + // Primary vertices' information + tree->SetBranchAddress( "nPrimVertexCand", &nPrimVertexCand ); + tree->SetBranchAddress( "PrimVertexCand_x", PrimVertexCand_x ); + tree->SetBranchAddress( "PrimVertexCand_y", PrimVertexCand_y ); + tree->SetBranchAddress( "PrimVertexCand_z", PrimVertexCand_z ); + tree->SetBranchAddress( "PrimVertexCand_chi2", PrimVertexCand_chi2 ); + tree->SetBranchAddress( "PrimVertexCand_ndof", PrimVertexCand_ndof ); + tree->SetBranchAddress( "PrimVertexCand_tracks", PrimVertexCand_tracks ); + + // Lepton pairs' information + tree->SetBranchAddress( "nPair", &nPair ); + tree->SetBranchAddress( "Pair_lepton1", Pair_lepton1 ); + tree->SetBranchAddress( "Pair_lepton2", Pair_lepton2 ); + //tree->SetBranchAddress( "Pair_mindist", Pair_mindist ); + tree->SetBranchAddress( "Pair_mass", Pair_mass ); + tree->SetBranchAddress( "Pair_pt", Pair_pt ); + tree->SetBranchAddress( "Pair_eta", Pair_eta ); + tree->SetBranchAddress( "Pair_phi", Pair_phi ); + tree->SetBranchAddress( "Pair_dpt", Pair_dpt ); + tree->SetBranchAddress( "Pair_dphi", Pair_dphi ); + tree->SetBranchAddress( "Pair_3Dangle", Pair_3Dangle ); + tree->SetBranchAddress( "Pair_extratracks0p5mm", Pair_extratracks0p5mm ); + tree->SetBranchAddress( "Pair_extratracks1mm", Pair_extratracks1mm ); + tree->SetBranchAddress( "Pair_extratracks2mm", Pair_extratracks2mm ); + tree->SetBranchAddress( "Pair_extratracks3mm", Pair_extratracks3mm ); + tree->SetBranchAddress( "Pair_extratracks4mm", Pair_extratracks4mm ); + tree->SetBranchAddress( "Pair_extratracks5mm", Pair_extratracks5mm ); + tree->SetBranchAddress( "Pair_extratracks1cm", Pair_extratracks1cm ); + tree->SetBranchAddress( "Pair_extratracks2cm", Pair_extratracks2cm ); + tree->SetBranchAddress( "Pair_extratracks3cm", Pair_extratracks3cm ); + tree->SetBranchAddress( "Pair_extratracks4cm", Pair_extratracks4cm ); + tree->SetBranchAddress( "Pair_extratracks5cm", Pair_extratracks5cm ); + tree->SetBranchAddress( "Pair_extratracks10cm", Pair_extratracks10cm ); + // Kalman dilepton vertex information + tree->SetBranchAddress( "KalmanVertexCand_x", KalmanVertexCand_x ); + tree->SetBranchAddress( "KalmanVertexCand_y", KalmanVertexCand_y ); + tree->SetBranchAddress( "KalmanVertexCand_z", KalmanVertexCand_z ); + + if ( mc ) { + tree->SetBranchAddress( "GenPair_mass", &GenPair_mass ); + tree->SetBranchAddress( "GenPair_pt", &GenPair_pt ); + tree->SetBranchAddress( "GenPair_eta", &GenPair_eta ); + tree->SetBranchAddress( "GenPair_phi", &GenPair_phi ); + tree->SetBranchAddress( "GenPair_dpt", &GenPair_dpt ); + tree->SetBranchAddress( "GenPair_dphi", &GenPair_dphi ); + tree->SetBranchAddress( "GenPair_3Dangle", &GenPair_3Dangle ); + } + + // if ( !mc ) { + if(1) { + tree->SetBranchAddress( "nLocalProtCand", &nLocalProtCand ); + tree->SetBranchAddress( "LocalProtCand_x", LocalProtCand_x ); + tree->SetBranchAddress( "LocalProtCand_y", LocalProtCand_y ); + tree->SetBranchAddress( "LocalProtCand_t", LocalProtCand_t ); + tree->SetBranchAddress( "LocalProtCand_xSigma", LocalProtCand_xSigma ); + tree->SetBranchAddress( "LocalProtCand_ySigma", LocalProtCand_ySigma ); + tree->SetBranchAddress( "LocalProtCand_tSigma", LocalProtCand_tSigma ); + tree->SetBranchAddress( "LocalProtCand_arm", LocalProtCand_arm ); + tree->SetBranchAddress( "LocalProtCand_station", LocalProtCand_station ); + tree->SetBranchAddress( "LocalProtCand_pot", LocalProtCand_pot ); + tree->SetBranchAddress( "LocalProtCand_rpid", LocalProtCand_rpid ); + + tree->SetBranchAddress( "nRecoProtCand", &nRecoProtCand ); + tree->SetBranchAddress( "ProtCand_xi", ProtCand_xi ); + tree->SetBranchAddress( "ProtCand_t", ProtCand_t ); + tree->SetBranchAddress( "ProtCand_ThX", ProtCand_ThX ); + tree->SetBranchAddress( "ProtCand_ThY", ProtCand_ThY ); + tree->SetBranchAddress( "ProtCand_rpid", ProtCand_rpid ); + tree->SetBranchAddress( "ProtCand_arm", ProtCand_arm ); + tree->SetBranchAddress( "ProtCand_ismultirp", ProtCand_ismultirp ); + + } + + // Extra tracks on vertex's information + if (storetracks == true) + { + tree->SetBranchAddress( "nExtraTracks", &nExtraTracks ); + tree->SetBranchAddress( "ExtraTrack_pair", ExtraTrack_pair ); + tree->SetBranchAddress( "ExtraTrack_purity", ExtraTrack_purity ); + tree->SetBranchAddress( "ExtraTrack_nhits", ExtraTrack_nhits ); + tree->SetBranchAddress( "ExtraTrack_charge", ExtraTrack_charge ); + tree->SetBranchAddress( "ExtraTrack_ndof", ExtraTrack_ndof ); + tree->SetBranchAddress( "ExtraTrack_px", ExtraTrack_px ); + tree->SetBranchAddress( "ExtraTrack_py", ExtraTrack_py ); + tree->SetBranchAddress( "ExtraTrack_pz", ExtraTrack_pz ); + tree->SetBranchAddress( "ExtraTrack_chi2", ExtraTrack_chi2 ); + tree->SetBranchAddress( "ExtraTrack_vtxdxyz", ExtraTrack_vtxdxyz ); + tree->SetBranchAddress( "ExtraTrack_vtxT", ExtraTrack_vtxT ); + tree->SetBranchAddress( "ExtraTrack_vtxZ", ExtraTrack_vtxZ ); + tree->SetBranchAddress( "ExtraTrack_x", ExtraTrack_x ); + tree->SetBranchAddress( "ExtraTrack_y", ExtraTrack_y ); + tree->SetBranchAddress( "ExtraTrack_z", ExtraTrack_z ); + } + tree->SetBranchAddress( "nQualityExtraTrack", &nQualityExtraTrack ); + tree->SetBranchAddress( "ClosestExtraTrack_vtxdxyz", ClosestExtraTrack_vtxdxyz ); + tree->SetBranchAddress( "ClosestExtraTrack_id", ClosestExtraTrack_id ); + tree->SetBranchAddress( "ClosestHighPurityExtraTrack_vtxdxyz", ClosestHighPurityExtraTrack_vtxdxyz ); + tree->SetBranchAddress( "ClosestHighPurityExtraTrack_id", ClosestHighPurityExtraTrack_id ); + + // Jets/MET information + + // Pileup reweighting + tree->SetBranchAddress( "Weight", &Weight ); + tree->SetBranchAddress( "PUWeightTrue", &PUWeightTrue ); + } + }; +} + +#endif + diff --git a/GammaGammaLeptonLepton/interface/HLTMatcher.h b/GammaGammaLeptonLepton/interface/HLTMatcher.h index 5aac76a..fbafdd2 100644 --- a/GammaGammaLeptonLepton/interface/HLTMatcher.h +++ b/GammaGammaLeptonLepton/interface/HLTMatcher.h @@ -6,25 +6,25 @@ #include #include +#include + // // class declaration // -class HLTMatcher { - public: - explicit HLTMatcher(std::vector); - ~HLTMatcher(); - int TriggerNum(std::string); - private: - std::vector HLTnames; -}; +namespace ggll +{ + class HLTMatcher { + public: + explicit HLTMatcher() {} + explicit HLTMatcher( const std::vector& ); + ~HLTMatcher() {} -// -// constants, enums and typedefs -// - -// -// static data member definitions -// + int TriggerNum( const std::string& ); + private: + std::vector HLTnames; + }; +} #endif + diff --git a/GammaGammaLeptonLepton/interface/PrimaryVertexSelector.h b/GammaGammaLeptonLepton/interface/PrimaryVertexSelector.h index 1e0f61d..f5a67a5 100644 --- a/GammaGammaLeptonLepton/interface/PrimaryVertexSelector.h +++ b/GammaGammaLeptonLepton/interface/PrimaryVertexSelector.h @@ -4,7 +4,7 @@ // system include files #include #include -#include +#include // Muons collection #include "DataFormats/PatCandidates/interface/Muon.h" @@ -17,44 +17,35 @@ #include "RecoEgamma/EgammaTools/interface/ConversionTools.h" // Vertices collection -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/Common/interface/RefToBase.h" -#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" -#include -#include +#include "TLorentzVector.h" // // class declaration // -class PrimaryVertexSelector : public reco::Vertex { +class PrimaryVertexSelector { public: - explicit PrimaryVertexSelector(std::vector&, std::map&, std::map&); - ~PrimaryVertexSelector(); - void SetPosition(double, double, double); - int AddTrack(const reco::TrackRef&, TString&); - inline int Electrons() { return nMatchedElectrons; } - inline int Muons() { return nMatchedMuons; } - double dZ(TVector3, int); - TVector3 Position; - int nTracks, nMatchedTracks, nUnmatchedTracks; - std::vector MatchedMuons, MatchedElectrons; - private: - unsigned int i; - int nMatchedMuons, nMatchedElectrons; - bool FetchMuons, FetchElectrons; - std::map MuonMomenta; - std::map ElectronMomenta; -}; + typedef std::vector< std::pair > MatchedLeptonsMap; -// -// constants, enums and typedefs -// + public: + explicit PrimaryVertexSelector(const std::map&, const std::map&); + inline ~PrimaryVertexSelector() {;} -// -// static data member definitions -// + void feedTracks(const reco::Vertex::trackRef_iterator&, const reco::Vertex::trackRef_iterator&); + + inline MatchedLeptonsMap matchedElectrons() const { return matchedElectrons_; } + int matchedElectron(const reco::TrackRef&) const; + + inline MatchedLeptonsMap matchedMuons() const { return matchedMuons_; } + int matchedMuon(const reco::TrackRef&) const; + + private: + typedef std::map LeptonsMap; + + LeptonsMap muonMomenta_, electronMomenta_; + MatchedLeptonsMap matchedMuons_, matchedElectrons_; +}; #endif diff --git a/GammaGammaLeptonLepton/interface/ProtonKinematics.h b/GammaGammaLeptonLepton/interface/ProtonKinematics.h new file mode 100644 index 0000000..3330242 --- /dev/null +++ b/GammaGammaLeptonLepton/interface/ProtonKinematics.h @@ -0,0 +1,66 @@ +#ifndef ProtonKinematics_h +#define ProtonKinematics_h + +#include "DataFormats/CTPPSReco/interface/TotemRPLocalTrack.h" + +/** + * \date Jun 2016 + * \author Jan Kaspar + * \author Laurent Forthomme + */ +class ProtonKinematics +{ + public: + /** + * \param[in] arm_id 0 (F), 1 (N) + * \param[in] side 0 (L), 1 (R) + */ + inline ProtonKinematics(unsigned int run_id, unsigned short arm_id, unsigned short side, const TotemRPLocalTrack& lt) : + fX0(lt.getX0()), fY0(lt.getY0()), fIsValid(lt.isValid()), fArm(arm_id), fSide(side) + { + if (run_id<274244) fRunPeriod = 0; + else fRunPeriod = 1; + } + inline bool isValid() const { return fIsValid; } + inline double getXi() const { + const double x_corr = fX0+getDeX(); + return x_corr*1e-3/getD(); + } + + private: + // alignment corrections (in m) + inline double getDeX() const { + switch (fSide) { + case 0: default: { return getDeX_L(); } + case 1: { return getDeX_R(); } + } + } + inline double getDeX_L() const { + switch (fRunPeriod) { + case 0: { return (fArm==0) ? -3.40 : -0.90; } + case 1: default: { return (fArm==0) ? -1.45 : -3.90; } + } + } + inline double getDeX_R() const { + switch (fRunPeriod) { + case 0: { return (fArm==0) ? -2.75 : -2.40; } + case 1: default: { return (fArm==0) ? -2.85 : -3.25; } + } + } + // optics properties (in m) + inline double getD() const { + switch (fSide) { + case 0: default: { return getD_L(); } + case 1: { return getD_R(); } + } + } + inline double getD_L() const { return (fArm==0) ? 9.22e-2 : 9.26e-2; } + inline double getD_R() const { return (fArm==0) ? 5.81e-2 : 5.16e-2; } + + double fX0, fY0; + bool fIsValid; + unsigned short fRunPeriod, fArm, fSide; + +}; + +#endif diff --git a/GammaGammaLeptonLepton/interface/SinglePhotonEvent.h b/GammaGammaLeptonLepton/interface/SinglePhotonEvent.h new file mode 100644 index 0000000..68a0117 --- /dev/null +++ b/GammaGammaLeptonLepton/interface/SinglePhotonEvent.h @@ -0,0 +1,321 @@ +#ifndef DiffractiveForwardAnalysis_GammaGammaLeptonLepton_SinglePhotonEvent_h +#define DiffractiveForwardAnalysis_GammaGammaLeptonLepton_SinglePhotonEvent_h + +#include +#include + +#include "TTree.h" + +namespace gggx +{ + class SinglePhotonEvent + { + public: + SinglePhotonEvent() : pHLT_Name( nullptr ) { + clear(); + } + ~SinglePhotonEvent() {} + + ////// Leaves size ////// + + /// Maximum number of HLT to check + static constexpr unsigned int MAX_HLT = 10; + /// Maximum number of photons per event + static constexpr unsigned int MAX_PHO = 50; + /// Maximum number of primary vertices per event + static constexpr unsigned int MAX_VTX = 150; + /// Maximum number of generator level photons per event + static constexpr unsigned int MAX_GENPHO = 10; + /// Maximum number of generator level protons per event + static constexpr unsigned int MAX_GENPRO = 8; + /// Maximum number of jets per event + static constexpr unsigned int MAX_JETS = 40; + /// Maximum number of reconstructed local tracks in RPs + static constexpr unsigned int MAX_FWDTRKCAND = 25; + + ////// Tree contents ////// + + // Run/event quantities + unsigned int BX, Run, LumiSection, EventNum; + //int LHCFillNum, LHCBeamMode; + //double AvgInstDelLumi, BunchInstLumi[3]; + + // HLT quantities + unsigned int nHLT; + int HLT_Accept[MAX_HLT], HLT_Prescl[MAX_HLT]; + std::vector HLT_Name, *pHLT_Name; + + // Generator level quantities + unsigned int nGenPhotCand, nGenPhotCandOutOfAccept; + double GenPhotCand_pt[MAX_GENPHO], GenPhotCand_eta[MAX_GENPHO], GenPhotCand_phi[MAX_GENPHO], GenPhotCand_e[MAX_GENPHO]; + unsigned int nGenProtCand; + double GenProtCand_pt[MAX_GENPRO], GenProtCand_eta[MAX_GENPRO], GenProtCand_phi[MAX_GENPRO], GenProtCand_e[MAX_GENPHO]; + int GenProtCand_status[MAX_GENPRO]; + + // Pileup reweighting quantities + double PUWeightTrue, Weight; + + // Photon quantities + unsigned int nPhotonCand; + double PhotonCand_pt[MAX_PHO], PhotonCand_eta[MAX_PHO], PhotonCand_phi[MAX_PHO], PhotonCand_e[MAX_PHO]; + double PhotonCand_r9[MAX_PHO]; + double PhotonCand_drtrue[MAX_PHO], PhotonCand_detatrue[MAX_PHO], PhotonCand_dphitrue[MAX_PHO]; + int PhotonCand_wp80id[MAX_PHO], PhotonCand_wp90id[MAX_PHO]; + int PhotonCand_electronveto[MAX_PHO], PhotonCand_pixelseed[MAX_PHO]; + + // Vertex quantities + unsigned int nPrimVertexCand; + double PrimVertexCand_x[MAX_VTX], PrimVertexCand_y[MAX_VTX], PrimVertexCand_z[MAX_VTX]; + unsigned int PrimVertexCand_tracks[MAX_VTX]; + double PrimVertexCand_chi2[MAX_VTX]; + unsigned int PrimVertexCand_ndof[MAX_VTX]; + unsigned int nFilteredPrimVertexCand; + + // Jets/MET quantities + unsigned int nJetCand; + double JetCand_pt[MAX_JETS], JetCand_eta[MAX_JETS], JetCand_phi[MAX_JETS], JetCand_e[MAX_JETS]; + double HighestJet_pt, HighestJet_eta, HighestJet_phi, HighestJet_e; + double SumJet_e; + double Etmiss, Etmiss_phi, Etmiss_significance; + + // PPS quantities + unsigned int nFwdTrkCand; + double FwdTrkCand_x[MAX_FWDTRKCAND], FwdTrkCand_y[MAX_FWDTRKCAND]; + double FwdTrkCand_xSigma[MAX_FWDTRKCAND], FwdTrkCand_ySigma[MAX_FWDTRKCAND]; + int FwdTrkCand_arm[MAX_FWDTRKCAND], FwdTrkCand_station[MAX_FWDTRKCAND], FwdTrkCand_pot[MAX_FWDTRKCAND]; + + void clear() { + // event-level branches + BX = Run = LumiSection = EventNum = 0; + + // high-level trigger + nHLT = 0; + HLT_Name.clear(); + for ( unsigned int i = 0; i < MAX_HLT; ++i ) + HLT_Accept[i] = HLT_Prescl[i] = -1; + + // gen-level information + nGenPhotCand = nGenPhotCandOutOfAccept = 0; + for ( unsigned int i = 0; i < MAX_GENPHO; ++i ) + GenPhotCand_pt[i] = GenPhotCand_eta[i] = GenPhotCand_phi[i] = GenPhotCand_e[i] = -999.; + nGenProtCand = 0; + for ( unsigned int i = 0; i < MAX_GENPRO; ++i ) { + GenProtCand_pt[i] = GenProtCand_eta[i] = GenProtCand_phi[i] = GenProtCand_e[i] = -999.; + GenProtCand_status[i] = -1; + } + + PUWeightTrue = Weight = 0.; + + //LHCFillNum = LHCBeamMode = -1; + + // single photon candidates + nPhotonCand = 0; + for ( unsigned int i = 0; i < MAX_PHO; ++i ) { + PhotonCand_pt[i] = PhotonCand_eta[i] = PhotonCand_phi[i] = PhotonCand_e[i] = -999.; + PhotonCand_r9[i] = -999.; + PhotonCand_drtrue[i] = PhotonCand_detatrue[i] = PhotonCand_dphitrue[i] = -999.; + PhotonCand_wp80id[i] = PhotonCand_wp90id[i] = -1; + PhotonCand_electronveto[i] = PhotonCand_pixelseed[i] = -1; + } + + // offline primary vertices + nPrimVertexCand = 0; + for ( unsigned int i = 0; i < MAX_VTX; ++i ) { + PrimVertexCand_x[i] = PrimVertexCand_y[i] = PrimVertexCand_z[i] = -999.; + PrimVertexCand_tracks[i] = 0; + PrimVertexCand_chi2[i] = -999.; + PrimVertexCand_ndof[i] = 0; + } + nFilteredPrimVertexCand = 0; + + // jets collection + nJetCand = 0; + for ( unsigned int i = 0; i < MAX_JETS; ++i ) { + JetCand_pt[i] = JetCand_eta[i] = JetCand_phi[i] = JetCand_e[i] = -999; + } + HighestJet_pt = HighestJet_eta = HighestJet_phi = HighestJet_e = -999.; + SumJet_e = 0.; + + // missing ET + Etmiss = Etmiss_phi = Etmiss_significance = -999.; + + // CTPPS strips leaves + nFwdTrkCand = 0; + for ( unsigned int i = 0; i < MAX_FWDTRKCAND; ++i ) { + FwdTrkCand_x[i] = FwdTrkCand_y[i] = FwdTrkCand_xSigma[i] = FwdTrkCand_ySigma[i] = -999.; + FwdTrkCand_arm[i] = FwdTrkCand_station[i] = FwdTrkCand_pot[i] = -1; + } + } + void attach( TTree* tree, bool mc ) { + if ( !tree ) + return; + + tree->Branch( "Run", &Run, "Run/i" ); + tree->Branch( "LumiSection", &LumiSection, "LumiSection/i" ); + tree->Branch( "BX", &BX, "BX/i" ); + tree->Branch( "EventNum", &EventNum, "EventNum/i" ); + + tree->Branch( "nHLT", &nHLT, "nHLT/i" ); + tree->Branch( "HLT_Accept", HLT_Accept, "HLT_Accept[nHLT]/I" ); + tree->Branch( "HLT_Prescl", HLT_Prescl, "HLT_Prescl[nHLT]/I" ); + pHLT_Name = &HLT_Name; + tree->Branch( "HLT_Name", "std::vector", &pHLT_Name ); + + tree->Branch( "nPhotonCand", &nPhotonCand, "nPhotonCand/i" ); + tree->Branch( "PhotonCand_pt", PhotonCand_pt, "PhotonCand_pt[nPhotonCand]/D" ); + tree->Branch( "PhotonCand_eta", PhotonCand_eta, "PhotonCand_eta[nPhotonCand]/D" ); + tree->Branch( "PhotonCand_phi", PhotonCand_phi, "PhotonCand_phi[nPhotonCand]/D" ); + tree->Branch( "PhotonCand_e", PhotonCand_e, "PhotonCand_e[nPhotonCand]/D" ); + tree->Branch( "PhotonCand_r9", PhotonCand_r9, "PhotonCand_r9[nPhotonCand]/D" ); + tree->Branch( "PhotonCand_drtrue", PhotonCand_drtrue, "PhotonCand_drtrue[nPhotonCand]/D" ); + tree->Branch( "PhotonCand_detatrue", PhotonCand_detatrue, "PhotonCand_detatrue[nPhotonCand]/D" ); + tree->Branch( "PhotonCand_dphitrue", PhotonCand_dphitrue, "PhotonCand_dphitrue[nPhotonCand]/D" ); + tree->Branch( "PhotonCand_wp80id", PhotonCand_wp80id, "PhotonCand_wp80id[nPhotonCand]/I" ); + tree->Branch( "PhotonCand_wp90id", PhotonCand_wp90id, "PhotonCand_wp90id[nPhotonCand]/I" ); + tree->Branch( "PhotonCand_electronveto", PhotonCand_electronveto, "PhotonCand_electronveto[nPhotonCand]/I" ); + tree->Branch( "PhotonCand_pixelseed", PhotonCand_pixelseed, "PhotonCand_pixelseed[nPhotonCand]/I" ); + + if ( mc ) { + tree->Branch( "nGenPhotCand", &nGenPhotCand, "nGenPhotCand/i" ); + tree->Branch( "nGenPhotCandOutOfAccept", &nGenPhotCandOutOfAccept, "nGenPhotCandOutOfAccept/I" ); + tree->Branch( "GenPhotCand_pt", GenPhotCand_pt, "GenPhotCand_pt[nGenPhotCand]/D" ); + tree->Branch( "GenPhotCand_eta", GenPhotCand_eta, "GenPhotCand_eta[nGenPhotCand]/D" ); + tree->Branch( "GenPhotCand_phi", GenPhotCand_phi, "GenPhotCand_phi[nGenPhotCand]/D" ); + tree->Branch( "GenPhotCand_e", GenPhotCand_e, "GenPhotCand_e[nGenPhotCand]/D" ); + + tree->Branch( "nGenProtCand", &nGenProtCand, "nGenProtCand/i" ); + tree->Branch( "GenProtCand_pt", GenProtCand_pt, "GenProtCand_pt[nGenProtCand]/D" ); + tree->Branch( "GenProtCand_eta", GenProtCand_eta, "GenProtCand_eta[nGenProtCand]/D" ); + tree->Branch( "GenProtCand_phi", GenProtCand_phi, "GenProtCand_phi[nGenProtCand]/D" ); + tree->Branch( "GenProtCand_e", GenProtCand_e, "GenProtCand_e[nGenProtCand]/D" ); + tree->Branch( "GenProtCand_status", GenProtCand_status, "GenProtCand_status[nGenProtCand]/I" ); + } + + // Primary vertices' information + tree->Branch( "nPrimVertexCand", &nPrimVertexCand, "nPrimVertexCand/i" ); + tree->Branch( "nFilteredPrimVertexCand", &nFilteredPrimVertexCand, "nFilteredPrimVertexCand/i" ); + tree->Branch( "PrimVertexCand_x", PrimVertexCand_x, "PrimVertexCand_x[nPrimVertexCand]/D" ); + tree->Branch( "PrimVertexCand_y", PrimVertexCand_y, "PrimVertexCand_y[nPrimVertexCand]/D" ); + tree->Branch( "PrimVertexCand_z", PrimVertexCand_z, "PrimVertexCand_z[nPrimVertexCand]/D" ); + tree->Branch( "PrimVertexCand_chi2", PrimVertexCand_chi2, "PrimVertexCand_chi2[nPrimVertexCand]/D" ); + tree->Branch( "PrimVertexCand_ndof", PrimVertexCand_ndof, "PrimVertexCand_ndof[nPrimVertexCand]/i" ); + tree->Branch( "PrimVertexCand_tracks", PrimVertexCand_tracks, "PrimVertexCand_tracks[nPrimVertexCand]/i" ); + + if ( !mc ) { + tree->Branch( "nFwdTrkCand", &nFwdTrkCand, "nFwdTrkCand/i" ); + tree->Branch( "FwdTrkCand_x", FwdTrkCand_x, "FwdTrkCand_x[nFwdTrkCand]/D" ); + tree->Branch( "FwdTrkCand_y", FwdTrkCand_y, "FwdTrkCand_y[nFwdTrkCand]/D" ); + tree->Branch( "FwdTrkCand_xSigma", FwdTrkCand_xSigma, "FwdTrkCand_xSigma[nFwdTrkCand]/D" ); + tree->Branch( "FwdTrkCand_ySigma", FwdTrkCand_ySigma, "FwdTrkCand_ySigma[nFwdTrkCand]/D" ); + tree->Branch( "FwdTrkCand_arm", FwdTrkCand_arm, "FwdTrkCand_arm[nFwdTrkCand]/I" ); + tree->Branch( "FwdTrkCand_station", FwdTrkCand_station, "FwdTrkCand_station[nFwdTrkCand]/I" ); + tree->Branch( "FwdTrkCand_pot", FwdTrkCand_pot, "FwdTrkCand_pot[nFwdTrkCand]/I" ); + } + + // Jets/MET information + tree->Branch( "nJetCand", &nJetCand, "nJetCand/i" ); + tree->Branch( "JetCand_pt", JetCand_pt, "JetCand_pt[nJetCand]/D" ); + tree->Branch( "JetCand_eta", JetCand_eta, "JetCand_eta[nJetCand]/D" ); + tree->Branch( "JetCand_phi", JetCand_phi, "JetCand_phi[nJetCand]/D" ); + tree->Branch( "JetCand_e", JetCand_e, "JetCand_e[nJetCand]/D" ); + tree->Branch( "HighestJet_pt", &HighestJet_pt, "HighestJet_pt/D" ); + tree->Branch( "HighestJet_eta", &HighestJet_eta, "HighestJet_eta/D" ); + tree->Branch( "HighestJet_phi", &HighestJet_phi, "HighestJet_phi/D" ); + tree->Branch( "HighestJet_e", &HighestJet_e, "HighestJet_e/D" ); + tree->Branch( "SumJet_e", &SumJet_e, "SumJet_e/D" ); + tree->Branch( "Etmiss", &Etmiss, "Etmiss/D" ); + tree->Branch( "Etmiss_phi", &Etmiss_phi, "Etmiss_phi/D" ); + tree->Branch( "Etmiss_significance", &Etmiss_significance, "Etmiss_significance/D" ); + + // Pileup reweighting + tree->Branch( "Weight", &Weight, "Weight/D" ); + tree->Branch( "PUWeightTrue", &PUWeightTrue, "PUWeightTrue/D" ); + } + void load( TTree* tree, bool mc ) { + if ( !tree ) return; + + tree->SetBranchAddress( "Run", &Run ); + tree->SetBranchAddress( "LumiSection", &LumiSection ); + tree->SetBranchAddress( "BX", &BX ); + tree->SetBranchAddress( "EventNum", &EventNum ); + + tree->SetBranchAddress( "nHLT", &nHLT ); + tree->SetBranchAddress( "HLT_Accept", HLT_Accept ); + tree->SetBranchAddress( "HLT_Prescl", HLT_Prescl ); + tree->SetBranchAddress( "HLT_Name", &pHLT_Name ); + + tree->SetBranchAddress( "nPhotonCand", &nPhotonCand ); + tree->SetBranchAddress( "PhotonCand_pt", PhotonCand_pt ); + tree->SetBranchAddress( "PhotonCand_eta", PhotonCand_eta ); + tree->SetBranchAddress( "PhotonCand_phi", PhotonCand_phi ); + tree->SetBranchAddress( "PhotonCand_e", PhotonCand_e ); + tree->SetBranchAddress( "PhotonCand_r9", PhotonCand_r9 ); + tree->SetBranchAddress( "PhotonCand_drtrue", PhotonCand_drtrue ); + tree->SetBranchAddress( "PhotonCand_detatrue", PhotonCand_detatrue ); + tree->SetBranchAddress( "PhotonCand_dphitrue", PhotonCand_dphitrue ); + tree->SetBranchAddress( "PhotonCand_wp80id", PhotonCand_wp80id ); + tree->SetBranchAddress( "PhotonCand_wp90id", PhotonCand_wp90id ); + tree->SetBranchAddress( "PhotonCand_electronveto", PhotonCand_electronveto ); + tree->SetBranchAddress( "PhotonCand_pixelseed", PhotonCand_pixelseed ); + + if ( mc ) { + tree->SetBranchAddress( "nGenPhotCand", &nGenPhotCand ); + tree->SetBranchAddress( "nGenPhotCandOutOfAccept", &nGenPhotCandOutOfAccept ); + tree->SetBranchAddress( "GenPhotCand_pt", GenPhotCand_pt ); + tree->SetBranchAddress( "GenPhotCand_eta", GenPhotCand_eta ); + tree->SetBranchAddress( "GenPhotCand_phi", GenPhotCand_phi ); + tree->SetBranchAddress( "GenPhotCand_e", GenPhotCand_e ); + + tree->SetBranchAddress( "nGenProtCand", &nGenProtCand ); + tree->SetBranchAddress( "GenProtCand_pt", GenProtCand_pt ); + tree->SetBranchAddress( "GenProtCand_eta", GenProtCand_eta ); + tree->SetBranchAddress( "GenProtCand_phi", GenProtCand_phi ); + tree->SetBranchAddress( "GenProtCand_e", GenProtCand_e ); + tree->SetBranchAddress( "GenProtCand_status", GenProtCand_status ); + } + + // Primary vertices' information + tree->SetBranchAddress( "nPrimVertexCand", &nPrimVertexCand ); + tree->SetBranchAddress( "nFilteredPrimVertexCand", &nFilteredPrimVertexCand ); + tree->SetBranchAddress( "PrimVertexCand_x", PrimVertexCand_x ); + tree->SetBranchAddress( "PrimVertexCand_y", PrimVertexCand_y ); + tree->SetBranchAddress( "PrimVertexCand_z", PrimVertexCand_z ); + tree->SetBranchAddress( "PrimVertexCand_chi2", PrimVertexCand_chi2 ); + tree->SetBranchAddress( "PrimVertexCand_ndof", PrimVertexCand_ndof ); + tree->SetBranchAddress( "PrimVertexCand_tracks", PrimVertexCand_tracks ); + + if ( !mc ) { + tree->SetBranchAddress( "nFwdTrkCand", &nFwdTrkCand ); + tree->SetBranchAddress( "FwdTrkCand_x", FwdTrkCand_x ); + tree->SetBranchAddress( "FwdTrkCand_y", FwdTrkCand_y ); + tree->SetBranchAddress( "FwdTrkCand_xSigma", FwdTrkCand_xSigma ); + tree->SetBranchAddress( "FwdTrkCand_ySigma", FwdTrkCand_ySigma ); + tree->SetBranchAddress( "FwdTrkCand_arm", FwdTrkCand_arm ); + tree->SetBranchAddress( "FwdTrkCand_station", FwdTrkCand_station ); + tree->SetBranchAddress( "FwdTrkCand_pot", FwdTrkCand_pot ); + } + + // Jets/MET information + tree->SetBranchAddress( "nJetCand", &nJetCand ); + tree->SetBranchAddress( "JetCand_pt", JetCand_pt ); + tree->SetBranchAddress( "JetCand_eta", JetCand_eta ); + tree->SetBranchAddress( "JetCand_phi", JetCand_phi ); + tree->SetBranchAddress( "JetCand_e", JetCand_e ); + tree->SetBranchAddress( "HighestJet_pt", &HighestJet_pt ); + tree->SetBranchAddress( "HighestJet_eta", &HighestJet_eta ); + tree->SetBranchAddress( "HighestJet_phi", &HighestJet_phi ); + tree->SetBranchAddress( "HighestJet_e", &HighestJet_e ); + tree->SetBranchAddress( "SumJet_e", &SumJet_e ); + tree->SetBranchAddress( "Etmiss", &Etmiss ); + tree->SetBranchAddress( "Etmiss_phi", &Etmiss_phi ); + tree->SetBranchAddress( "Etmiss_significance", &Etmiss_significance ); + + // Pileup reweighting + tree->SetBranchAddress( "Weight", &Weight ); + tree->SetBranchAddress( "PUWeightTrue", &PUWeightTrue ); + } + }; +} + +#endif + diff --git a/GammaGammaLeptonLepton/plugins/GammaGammaLL.cc b/GammaGammaLeptonLepton/plugins/GammaGammaLL.cc index 181ecdd..ea2bac4 100644 --- a/GammaGammaLeptonLepton/plugins/GammaGammaLL.cc +++ b/GammaGammaLeptonLepton/plugins/GammaGammaLL.cc @@ -2,8 +2,8 @@ // // Package: GammaGammaLL // Class: GammaGammaLL -// -/**\class GammaGammaLL GammaGammaLL.cc DiffractiveForwardAnalysis/GammaGammaLeptonLepton/src/GammaGammaLL.cc +// +/**\class GammaGammaLL GammaGammaLL.cc DiffractiveForwardAnalysis/GammaGammaLeptonLepton/plugins/GammaGammaLL.cc Description: [one line class summary] @@ -17,1225 +17,981 @@ // // -#include "GammaGammaLL.h" +// system include files +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/Registry.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +// L1 collections +#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h" +#include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEmCand.h" + +#include "DataFormats/Luminosity/interface/LumiSummary.h" +#include "DataFormats/Luminosity/interface/LumiDetails.h" + +// HLT information +#include "DataFormats/PatCandidates/interface/TriggerEvent.h" +#include "DataFormats/Common/interface/TriggerResults.h" +#include "FWCore/Common/interface/TriggerNames.h" +#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h" +#include "HLTrigger/HLTcore/interface/HLTPrescaleProvider.h" + +// Generator level collection +#include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +// Pileup +#include "PhysicsTools/Utilities/interface/LumiReWeighting.h" +//#include "DiffractiveForwardAnalysis/Utilities/interface/LumiReWeighting.h" +#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" + +// Muons collection +#include "DataFormats/PatCandidates/interface/Muon.h" +#include "DataFormats/MuonReco/interface/Muon.h" +//#include "DataFormats/MuonReco/interface/MuonFwd.h" +//#include "DataFormats/MuonReco/interface/MuonSelectors.h" + +// Electrons collection +#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" +#include "DataFormats/PatCandidates/interface/Electron.h" +//#include "EgammaAnalysis/ElectronTools/interface/EGammaCutBasedEleId.h" +//#include "EGamma/EGammaAnalysisTools/interface/EGammaCutBasedEleId.h" +#include "DataFormats/EgammaCandidates/interface/Conversion.h" +#include "RecoEgamma/EgammaTools/interface/ConversionTools.h" +//// tweaked electron ID +//#include "DiffractiveForwardAnalysis/GammaGammaLeptonLepton/interface/ElectronID.h" + +// Particle flow collection +//#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +//#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" + +// Vertices collection +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/Common/interface/RefToBase.h" +#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" + + +// PPS objects +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ProtonTrack.h" + + +#include "DiffractiveForwardAnalysis/GammaGammaLeptonLepton/interface/HLTMatcher.h" +#include "DiffractiveForwardAnalysis/GammaGammaLeptonLepton/interface/AnalysisEvent.h" +#include "DiffractiveForwardAnalysis/GammaGammaLeptonLepton/interface/PrimaryVertexSelector.h" + +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/TransientTrack/interface/TransientTrack.h" +#include "RecoVertex/KalmanVertexFit/interface/KalmanVertexFitter.h" + +// LHC fill information +//#include "DataFormats/Common/interface/ConditionsInEdm.h" // L1 method +//#include "CondFormats/RunInfo/interface/FillInfo.h" +//#include "CondFormats/DataRecord/interface/FillInfoRcd.h" // db method +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "TFile.h" +#include "TTree.h" +#include "TVector3.h" +#include "TLorentzVector.h" +#include "TH1D.h" + +#include + +typedef std::vector< edm::Handle< edm::ValueMap > > IsoDepositVals; // -// constructors and destructor +// class declaration // -GammaGammaLL::GammaGammaLL(const edm::ParameterSet& iConfig) : - //beamSpotToken_(consumes(iConfig.getParameter("beamSpotInputTag"))), - recoVertexToken_(consumes(iConfig.getParameter("RecoVertexLabel"))), - //genToken_(0), - muonToken_ (consumes< edm::View > (iConfig.getUntrackedParameter("GlobalMuonCollectionLabel", std::string("muons")))), - eleToken_ (consumes< edm::View > (iConfig.getUntrackedParameter("GlobalEleCollectionLabel", std::string("gsfElectrons")))), - eleLooseIdMapToken_ (consumes< edm::ValueMap > (iConfig.getParameter("eleLooseIdMap"))), - eleMediumIdMapToken_(consumes< edm::ValueMap > (iConfig.getParameter("eleMediumIdMap"))), - eleTightIdMapToken_ (consumes< edm::ValueMap > (iConfig.getParameter("eleTightIdMap"))), - conversionsToken_ (consumes (iConfig.getParameter("conversionsInputTag"))), - pileupToken_ (consumes< std::vector > (iConfig.getUntrackedParameter("pileupInfo", std::string("addPileupInfo")))), - pflowToken_ (consumes< edm::View >(iConfig.getUntrackedParameter("PFLabel", std::string("particleFlow")))), - jetToken_ (consumes< edm::View > (iConfig.getParameter("JetCollectionLabel"))), - metToken_ (consumes< edm::View > (iConfig.getParameter("MetLabel"))), - runOnMC_ (iConfig.getUntrackedParameter("RunOnMC", true)), - sqrts_ (iConfig.getParameter("SqrtS")), - hltPrescale_ (iConfig, consumesCollector(), *this) + +class GammaGammaLL : public edm::one::EDAnalyzer +{ + public: + explicit GammaGammaLL( const edm::ParameterSet& ); + ~GammaGammaLL() {} + + static void fillDescriptions( edm::ConfigurationDescriptions& descriptions ); + + private: + void beginJob() override; + void beginRun( const edm::Run&, const edm::EventSetup& ) override; + void analyze( const edm::Event&, const edm::EventSetup& ) override; + void endRun( const edm::Run&, const edm::EventSetup& ) override {} + void endJob() override; + + void lookAtTriggers( const edm::Event&, const edm::EventSetup& ); + void analyzeMCEventContent( const edm::Event& ); + + void fetchElectrons( const edm::Event& ); + void fetchMuons( const edm::Event& ); + void fetchProtons( const edm::Event& ); + void fetchVertices( const edm::Event& ); + + void newVertexInfoRetrieval( const edm::Event& ); + bool newTracksInfoRetrieval( int, int ); + + // ----------member data --------------------------- + ggll::TreeType leptonsType_; + + TTree* tree_; + ggll::AnalysisEvent evt_; + + bool fetchMuons_, fetchElectrons_, fetchProtons_; + bool foundPairInEvent_; + + // Input tags + edm::InputTag triggerResults_; + std::vector triggersList_; + + edm::EDGetTokenT triggerEventToken_; + edm::EDGetTokenT triggerResultsToken_; + edm::EDGetTokenT > pileupToken_; + edm::EDGetTokenT > recoVertexToken_; + edm::EDGetTokenT > recoTrackToken_; + edm::EDGetTokenT > genToken_; + edm::EDGetTokenT > muonToken_; + edm::EDGetTokenT > eleToken_; + /*edm::EDGetTokenT > eleMediumIdMapToken_, eleTightIdMapToken_; + edm::EDGetTokenT > phoMediumIdMapToken_, phoTightIdMapToken_;*/ + edm::EDGetTokenT fixedGridRhoFastjetAllToken_; + edm::EDGetTokenT > ppsLocalTrackToken_; + edm::EDGetTokenT > recoProtonsToken_; + + bool runOnMC_, printCandidates_; + double minPtMC_, minEtaMC_; + double sqrts_; + bool saveExtraTracks_; + std::string year_; + + // Trigger information + ggll::HLTMatcher hlts_; + HLTConfigProvider hltConfig_; + HLTPrescaleProvider hltPrescale_; + + unsigned int maxExTrkVtx_; + double minMpair_, maxMpair_; + + // E/gamma identification + edm::ParameterSet eleIdLabelSet_; + std::string eleMediumIdLabel_, eleTightIdLabel_; + edm::ParameterSet phoIdLabelSet_; + std::string phoMediumIdLabel_, phoTightIdLabel_; + + // Pileup information + edm::LumiReWeighting lumiWeights_; + std::string mcPileupFile_, dataPileupFile_; + std::string mcPileupPath_, dataPileupPath_; + + edm::Handle > trackColl_; + edm::ESHandle KalVtx_; + std::map muonsMomenta_, electronsMomenta_; + std::map muonTransientTracks_, eleTransientTracks_; + + unsigned int nCandidates_; +}; + +const unsigned int ggll::AnalysisEvent::MAX_ET; + +GammaGammaLL::GammaGammaLL( const edm::ParameterSet& iConfig ) : + tree_( 0 ), + fetchMuons_( false ), fetchElectrons_( false ), + fetchProtons_ ( iConfig.getParameter( "fetchProtons" ) ), + triggerResults_ ( iConfig.getParameter ( "triggerResults" ) ), + triggersList_ ( iConfig.getParameter >( "triggersList" ) ), + triggerResultsToken_( consumes ( iConfig.getParameter( "triggerResults" ) ) ), + pileupToken_ ( consumes > ( iConfig.getParameter( "pileupInfo" ) ) ), + recoVertexToken_ ( consumes > ( iConfig.getParameter( "vertexTag" ) ) ), + recoTrackToken_ ( consumes > ( iConfig.getParameter( "trackTag" ) ) ), + muonToken_ ( consumes > ( iConfig.getParameter( "muonTag" ) ) ), + eleToken_ ( consumes > ( iConfig.getParameter( "electronTag" ) ) ), + /*eleMediumIdMapToken_( consumes > ( iConfig.getParameter( "eleMediumIdMap" ) ) ), + eleTightIdMapToken_ ( consumes > ( iConfig.getParameter( "eleTightIdMap" ) ) ), + phoMediumIdMapToken_( consumes > ( iConfig.getParameter( "phoMediumIdMap" ) ) ), + phoTightIdMapToken_ ( consumes > ( iConfig.getParameter( "phoTightIdMap" ) ) ),*/ + fixedGridRhoFastjetAllToken_( consumes ( iConfig.getParameter( "fixedGridRhoFastjetAllLabel" ) ) ), + ppsLocalTrackToken_ ( consumes > ( iConfig.getParameter( "ppsLocalTrackTag" ) ) ), + recoProtonsToken_ ( consumes > ( iConfig.getParameter( "ppsRecoProtonTag" ) ) ), + runOnMC_ ( iConfig.getParameter( "runOnMC" ) ), + printCandidates_ ( iConfig.getParameter( "printCandidates" ) ), + sqrts_ ( iConfig.getParameter( "sqrtS" ) ), + saveExtraTracks_ ( iConfig.getParameter( "saveExtraTracks" ) ), + year_ ( iConfig.getParameter( "year" ) ), + hlts_ ( triggersList_ ), + hltPrescale_ ( iConfig, consumesCollector(), *this ), + // Central selection + maxExTrkVtx_ ( iConfig.getUntrackedParameter( "maxExtraTracks", ggll::AnalysisEvent::MAX_ET ) ), + minMpair_ ( iConfig.getUntrackedParameter( "minMpair", -1. ) ), + maxMpair_ ( iConfig.getUntrackedParameter( "maxMpair", -1. ) ), + // Pileup input tags + mcPileupFile_ ( iConfig.getParameter( "mcpufile" ) ), + dataPileupFile_ ( iConfig.getParameter( "datapufile" ) ), + mcPileupPath_ ( iConfig.getParameter( "mcpupath" ) ), + dataPileupPath_ ( iConfig.getParameter( "datapupath" ) ), + nCandidates_( 0 ) { - //now do what ever initialization is needed - _fetchMuons = false; - _fetchElectrons = false; - outputFile_ = iConfig.getUntrackedParameter("outfilename", "output.root"); - - hltMenuLabel_ = iConfig.getParameter("HLTMenuLabel"); - triggersList_ = iConfig.getParameter >("TriggersList"); - _hlts = new HLTMatcher(triggersList_); - nHLT = triggersList_.size(); - - maxExTrkVtx_ = iConfig.getUntrackedParameter("maxExtraTracks", 1000); - // Generator level - if (runOnMC_) { - genToken_ = consumes(iConfig.getParameter("GenParticlesCollectionLabel")); + if ( runOnMC_ ) { + genToken_ = consumes >( iConfig.getParameter( "genParticleTag" ) ); + minPtMC_ = iConfig.getUntrackedParameter( "MCAcceptPtCut", 10. ); + minEtaMC_ = iConfig.getUntrackedParameter( "MCAcceptEtaCut", 2.5 ); } - minPtMC_ = iConfig.getUntrackedParameter("MCAcceptPtCut", 20.); - minEtaMC_ = iConfig.getUntrackedParameter("MCAcceptEtaCut", 2.5); - - // Pileup input tags - mcPileupFile_ = iConfig.getUntrackedParameter("mcpufile", "PUHistos.root"); - mcPileupPath_ = iConfig.getUntrackedParameter("mcpupath", "pileup"); - dataPileupFile_ = iConfig.getUntrackedParameter("datapufile", "PUHistos_duplicated.root"); - dataPileupPath_ = iConfig.getUntrackedParameter("datapupath", "pileup"); - + // Leptons input tags - leptonsType_ = iConfig.getParameter< std::vector >("LeptonsType"); - for (i=0; i( "leptonsType" ); + if ( ltype == "ElectronMuon" ) { + leptonsType_ = ggll::ElectronMuon; + fetchElectrons_ = true; + fetchMuons_ = true; } - ///isoValToken_ = consumes >("isoValInputTags"); - - printCandidates_ = iConfig.getUntrackedParameter("PrintCandidates", false); - - file_ = new TFile(outputFile_.c_str(), "recreate"); - file_->cd(); - // tree definition - tree_ = new TTree("ntp1", "ntp1"); - - //log_hist = new TH1D("log", "", 500, -25., 25.); - logfile = new std::ofstream("log_file.out"); - - // HPS acceptance file readout definition - if (runOnMC_) { - // edm::FileInPath myDataFile("FastSimulation/ProtonTaggers/data/acceptance_420_220.root"); - /*myDataFile = new edm::FileInPath("FastSimulation/ForwardDetectors/data/acceptance_420_220.root"); - fullAcceptancePath = myDataFile->fullPath(); - std::cout << "Opening " << fullAcceptancePath << std::endl; - f = new TFile(fullAcceptancePath.c_str()); - if (f->Get("description") != NULL) { - std::cout << "Description found: " << f->Get("description")->GetTitle() << std::endl; - std::cout << "Reading acceptance tables " << std::endl; - } - helper420beam1.Init(*f, "a420"); - helper420beam2.Init(*f, "a420_b2"); - helper220beam1.Init(*f, "a220"); - helper220beam2.Init(*f, "a220_b2"); - helper420a220beam1.Init(*f, "a420a220"); - helper420a220beam2.Init(*f, "a420a220_b2");*/ - - LumiWeights = new edm::LumiReWeighting(mcPileupFile_, dataPileupFile_, mcPileupPath_, dataPileupPath_); + else if ( ltype == "Muon" ) { + leptonsType_ = ggll::DiMuon; + fetchMuons_ = true; + } + else if ( ltype == "Electron" ) { + leptonsType_ = ggll::DiElectron; + fetchElectrons_ = true; + } + else throw cms::Exception( "GammaGammaLL" ) << "'LeptonsType' parameter should either be:\n" + << " * 'ElectronMuon' (for mixed leptons pair)\n" + << " * 'Electron' or 'Muon' (for same-flavour leptons)"; + + if ( fetchElectrons_ ) { + // electron identification variables + const edm::ParameterSet eleIdLabelSet = iConfig.getParameter( "eleIdLabels" ); + eleMediumIdLabel_ = eleIdLabelSet.getParameter( "mediumLabel" ).encode(); + eleTightIdLabel_ = eleIdLabelSet.getParameter( "tightLabel" ).encode(); } -} - - -GammaGammaLL::~GammaGammaLL() -{ - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) - /*const edm::ParameterSet& pset = edm::getProcessParameterSet(); - TList *list = tree_->GetUserInfo(); - list->Add(new TObjString(pset.dump().c_str()));*/ - file_->Write(); - file_->Close(); - - logfile->close(); - - logfile->close(); - - delete _hlts; - delete tree_; + // Pileup reweighting utilities + if ( runOnMC_ ) + lumiWeights_ = edm::LumiReWeighting( mcPileupFile_, dataPileupFile_, mcPileupPath_, dataPileupPath_ ); + // Book the output tree + usesResource( "TFileService" ); + edm::Service fs; + tree_ = fs->make( "ntp1", "ntp1" ); } - -// -// member functions -// - void -GammaGammaLL::LookAtTriggers(const edm::Event& iEvent, const edm::EventSetup& iSetup) +GammaGammaLL::lookAtTriggers( const edm::Event& iEvent, const edm::EventSetup& iSetup ) { - int trigNum; - // Get the trigger information from the event - iEvent.getByLabel(edm::InputTag("TriggerResults","",hltMenuLabel_),hltResults_) ; - const edm::TriggerNames & trigNames = iEvent.triggerNames(*hltResults_); - - for (unsigned int i=0; i " << trigNames.triggerNames().at(i) << std::endl; - trigNum = _hlts->TriggerNum(trigNames.triggerNames().at(i)); - if (trigNum==-1) continue; // Trigger didn't match the interesting ones - HLT_Accept[trigNum] = hltResults_->accept(i) ? 1 : 0; - int prescale_set = hltPrescale_.prescaleSet(iEvent, iSetup); - HLT_Prescl[trigNum] = hltConfig_.prescaleValue(prescale_set, trigNames.triggerNames().at(i)); - - //LF FIXME need to think about that implementation... - /*if (trigNames.triggerNames().at(i).find("CaloIdL")) {} // Leading lepton - else if (trigNames.triggerNames().at(i).find("CaloIdT")) {} // Trailing lepton*/ - //std::cout << "*-------> " << trigNames.triggerNames().at(i).substr(0, trigNames.triggerNames().at(i).find_last_of("_")); - //HLT_LeadingLepton_Prescl[] = hltConfig_.prescaleValue(event, iSetup, "HLT_Mu8Ele17L"); + evt_.nHLT = triggersList_.size(); + edm::Handle hltResults; + iEvent.getByToken( triggerResultsToken_, hltResults); + const edm::TriggerNames& trigNames = iEvent.triggerNames(*hltResults); + + std::ostringstream os; + os << "Prescale set: " << hltPrescale_.prescaleSet(iEvent, iSetup) << "\n" + << "Trigger names: " << std::endl; + for ( unsigned int i = 0; i < trigNames.size(); ++i ) { + os << "* " << trigNames.triggerNames().at( i ) << std::endl; + + // ensure trigger matches the interesting ones + const int trigNum = hlts_.TriggerNum( trigNames.triggerNames().at( i ) ); + if ( trigNum < 0 ) + continue; + + evt_.HLT_Accept[trigNum] = hltResults->accept( i ); + + if ( !evt_.HLT_Accept[trigNum] ) + continue; + // extract prescale value for this path + if ( !iEvent.isRealData() ) { + evt_.HLT_Prescl[trigNum] = 1.; + continue; + } //FIXME + int prescale_set = hltPrescale_.prescaleSet( iEvent, iSetup ); + if ( prescale_set >= 0 ) + evt_.HLT_Prescl[trigNum] = hltConfig_.prescaleValue( prescale_set, trigNames.triggerNames().at( i ) ); + /*std::pair prescales = hltPrescale_.prescaleValues( iEvent, iSetup, trigNames.triggerNames().at( i ) ); + //std::cout << "trigger path " << trigNames.triggerNames().at( i ) << " has L1/HLT prescales: " << prescales.first << "/" << prescales.second + // << " event r/l/e: " << iEvent.id().run() << "/" << iEvent.luminosityBlock() << "/" << iEvent.id().event() << std::endl; + evt_.HLT_Prescl[trigNum] = prescales.second;*/ } + //std::cout + LogDebug( "GammaGammaLL" ) + << os.str(); } // ------------ method called for each event ------------ void -GammaGammaLL::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +GammaGammaLL::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup ) { - using namespace edm; - //std::cout << "Beginning First init" << std::endl; + // Kalman filtering + iSetup.get().get( "TransientTrackBuilder", KalVtx_ ); // First initialization of the variables - nCandidatesInEvent = 0; - nPrimVertexCand = nFilteredPrimVertexCand = -1; - nMuonCand = nEleCand = nLeptonCand = 0; - nExtraTracks = nQualityExtraTrack = 0; - nJetCand = 0; - nGenMuonCand = nGenMuonCandOutOfAccept = 0; - nGenEleCand = nGenEleCandOutOfAccept = 0; - nGenPhotCand = nGenPhotCandOutOfAccept = 0; - nGenProtCand = 0; - nPFPhotonCand = 0; - - HPS_acc420b1 = HPS_acc220b1 = HPS_acc420and220b1 = HPS_acc420or220b1 = -1; - HPS_acc420b2 = HPS_acc220b2 = HPS_acc420and220b2 = HPS_acc420or220b2 = -1; - GenPair_p = GenPair_pt = GenPair_mass = GenPair_phi = GenPair_eta = -999.; - GenPair_dphi = GenPair_dpt = GenPair_3Dangle = 0.; - - closesttrkdxyz = closesthighpuritytrkdxyz = 999.; - for (i=0; i pSetup; + const string label = ""; + iSetup.get().get(label, pSetup); + + // re-initialise algorithm upon crossing-angle change + const LHCInfo* pInfo = pSetup.product(); + evt_.CrossingAngle = pInfo->crossingAngle(); + } + else + evt_.CrossingAngle = -999; // Generator level information - if (runOnMC_) { - iEvent.getByToken(genToken_, genPartColl); - - for (genPart=genPartColl->begin(); genPart!=genPartColl->end(); genPart++) { - if (genPart->pt()eta())>minEtaMC_)) { - if (fabs(genPart->pdgId())==13) nGenMuonCandOutOfAccept++; - if (fabs(genPart->pdgId())==11) nGenEleCandOutOfAccept++; - if (fabs(genPart->pdgId())==22) nGenPhotCandOutOfAccept++; - continue; - } - if (genPart->pdgId()==2212 && nGenProtCandp(); - GenProtCand_px[nGenProtCand] = genPart->px(); - GenProtCand_py[nGenProtCand] = genPart->py(); - GenProtCand_pz[nGenProtCand] = genPart->pz(); - GenProtCand_pt[nGenProtCand] = genPart->pt(); - GenProtCand_eta[nGenProtCand] = genPart->eta(); - GenProtCand_phi[nGenProtCand] = genPart->phi(); - GenProtCand_status[nGenProtCand] = genPart->status(); - - nGenProtCand++; - } - if (fabs(genPart->pdgId())==13 && nGenMuonCandp(); - GenMuonCand_px[nGenMuonCand] = genPart->px(); - GenMuonCand_py[nGenMuonCand] = genPart->py(); - GenMuonCand_pz[nGenMuonCand] = genPart->pz(); - GenMuonCand_pt[nGenMuonCand] = genPart->pt(); - GenMuonCand_eta[nGenMuonCand] = genPart->eta(); - GenMuonCand_phi[nGenMuonCand] = genPart->phi(); - - nGenMuonCand++; - } - if (fabs(genPart->pdgId())==11 && nGenEleCandp(); - GenEleCand_px[nGenEleCand] = genPart->px(); - GenEleCand_py[nGenEleCand] = genPart->py(); - GenEleCand_pz[nGenEleCand] = genPart->pz(); - GenEleCand_pt[nGenEleCand] = genPart->pt(); - GenEleCand_eta[nGenEleCand] = genPart->eta(); - GenEleCand_phi[nGenEleCand] = genPart->phi(); - - nGenEleCand++; - } - if (genPart->pdgId()==22 && nGenPhotCandenergy(); - GenPhotCand_p[nGenPhotCand] = genPart->p(); - GenPhotCand_pt[nGenPhotCand] = genPart->pt(); - GenPhotCand_eta[nGenPhotCand] = genPart->eta(); - GenPhotCand_phi[nGenPhotCand] = genPart->phi(); - - nGenPhotCand++; - } - foundGenCandPairInEvent = false; - if (_fetchElectrons && _fetchMuons) { // Looks at electron+muon - if(nGenMuonCand!=1 || nGenEleCand!=1) continue; // FIXME maybe a bit tight according to the newer PU conditions? - l1.SetXYZM(GenMuonCand_px[0], GenMuonCand_py[0], GenMuonCand_pz[0], MASS_MU); - l2.SetXYZM(GenEleCand_px[0], GenEleCand_py[0], GenEleCand_pz[0], MASS_E); - foundGenCandPairInEvent = true; - } - else if (_fetchElectrons) { // Looks at dielectrons - if(nGenEleCand!=2) continue; // FIXME maybe a bit tight according to the newer PU conditions? - l1.SetXYZM(GenEleCand_px[0], GenEleCand_py[0], GenEleCand_pz[0], MASS_E); - l2.SetXYZM(GenEleCand_px[1], GenEleCand_py[1], GenEleCand_pz[1], MASS_E); - foundGenCandPairInEvent = true; - } - else if (_fetchMuons) { // Looks at dimuons - if(nGenMuonCand!=2) continue; // FIXME maybe a bit tight according to the newer PU conditions? - l1.SetXYZM(GenMuonCand_px[0], GenMuonCand_py[0], GenMuonCand_pz[0], MASS_MU); - l2.SetXYZM(GenMuonCand_px[1], GenMuonCand_py[1], GenMuonCand_pz[1], MASS_MU); - foundGenCandPairInEvent = true; - } - if (foundGenCandPairInEvent) { - pair = l1+l2; - GenPair_p = pair.P(); - GenPair_pt = pair.Pt(); - GenPair_mass = pair.M(); - GenPair_phi = pair.Phi(); - GenPair_eta = pair.Eta(); - dphi = fabs(l1.Phi()-l2.Phi()); - GenPair_dphi = (dphipdgId()==2212 && fabs(genPart->pz())>3000.) { - // Kinematic quantities computation - // xi = fractional momentum loss - if (genPart->pz()>0.) xi = 1.-genPart->pz()/sqrts_; - else xi = 1.+genPart->pz()/sqrts_; - t = -(std::pow(genPart->pt(), 2)+std::pow(MASS_P*xi, 2))/(1.-xi); - - // HPS acceptance computation - if(genPart->pz()>0.) { - HPS_acc420b1 = helper420beam1.GetAcceptance(t, xi, genPart->phi()); - HPS_acc220b1 = helper220beam1.GetAcceptance(t, xi, genPart->phi()); - HPS_acc420and220b1 = helper420a220beam1.GetAcceptance(t, xi, genPart->phi()); - HPS_acc420or220b1 = HPS_acc420b1 + HPS_acc220b1 - HPS_acc420and220b1; - } - else { - HPS_acc420b2 = helper420beam2.GetAcceptance(t, xi, genPart->phi()); - HPS_acc220b2 = helper220beam2.GetAcceptance(t, xi, genPart->phi()); - HPS_acc420and220b2 = helper420a220beam2.GetAcceptance(t, xi, genPart->phi()); - HPS_acc420or220b2 = HPS_acc420b2 + HPS_acc220b2 - HPS_acc420and220b2; - } - } - } - } + if ( runOnMC_ ) { + analyzeMCEventContent( iEvent ); - // Pileup information - if (runOnMC_) { - iEvent.getByToken(pileupToken_, pileupInfo); + // Pileup information + edm::Handle > pu_info; + iEvent.getByToken( pileupToken_, pu_info); - // This part is optional if the distributions are already generated - sum_nvtx = 0; - npv = npvtrue = npvm1true = npvp1true = npv0true = npv0 = 0; - for(PVI=pileupInfo->begin(); PVI!=pileupInfo->end(); PVI++) { - beamXing = PVI->getBunchCrossing(); + int npv0true = 0; + for ( unsigned int i = 0; i < pu_info->size(); ++i ) { + const edm::Ptr PVI = pu_info->ptrAt( i); - npv = PVI->getPU_NumInteractions(); - npvtrue = PVI->getTrueNumInteractions(); - sum_nvtx += npvtrue; - - if(beamXing == -1) npvm1true+=npvtrue; - if(beamXing == 0) { - npv0 += npv; - npv0true += npvtrue; - } - if(beamXing == 1) npvp1true+=npvtrue; - } - nTruePUforPUWeightBX0 = npv0true; - // - - const edm::EventBase* iEventB = dynamic_cast(&iEvent); - Weight = LumiWeights->weight(*iEventB); - } - - //std::cout << "Passed Pileup" << std::endl; + const int beamXing = PVI->getBunchCrossing(), + npvtrue = PVI->getTrueNumInteractions(); - // Get the muons collection from the event - if (_fetchMuons) { - iEvent.getByToken(muonToken_, muonColl); - for (muon=muonColl->begin(); muon!=muonColl->end() && nMuonCandp(); - MuonCand_px[nMuonCand] = muon->px(); - MuonCand_py[nMuonCand] = muon->py(); - MuonCand_pz[nMuonCand] = muon->pz(); - MuonCand_pt[nMuonCand] = muon->pt(); - MuonCand_eta[nMuonCand] = muon->eta(); - MuonCand_phi[nMuonCand] = muon->phi(); - MuonCand_charge[nMuonCand] = muon->charge(); - MuonCand_dxy[nMuonCand] = muon->dB(); - MuonCand_nstatseg[nMuonCand] = muon->numberOfMatchedStations(); - - MuonCand_vtxx[nMuonCand] = muon->vertex().x(); - MuonCand_vtxy[nMuonCand] = muon->vertex().y(); - MuonCand_vtxz[nMuonCand] = muon->vertex().z(); - - MuonCand_isglobal[nMuonCand] = muon->isGlobalMuon(); - MuonCand_istracker[nMuonCand] = muon->isTrackerMuon(); - MuonCand_isstandalone[nMuonCand] = muon->isStandAloneMuon(); - MuonCand_ispfmuon[nMuonCand] = muon->isPFMuon(); - - if (MuonCand_istracker[nMuonCand]) { - MuonCand_npxlhits[nMuonCand] = muon->innerTrack()->hitPattern().numberOfValidPixelHits(); - MuonCand_ntrklayers[nMuonCand] = muon->innerTrack()->hitPattern().trackerLayersWithMeasurement(); - _leptonptmp->SetXYZM(muon->innerTrack()->px(), muon->innerTrack()->py(), muon->innerTrack()->pz(), muon->mass()); - } - else { - _leptonptmp->SetXYZM(muon->px(), muon->py(), muon->pz(), muon->mass()); - } - muonsMomenta.insert(std::pair(nMuonCand, *_leptonptmp)); - - if (MuonCand_isglobal[nMuonCand] && MuonCand_istracker[nMuonCand]) { - MuonCandTrack_nmuchits[nMuonCand] = muon->globalTrack()->hitPattern().numberOfValidMuonHits(); - MuonCandTrack_chisq[nMuonCand] = muon->globalTrack()->normalizedChi2(); - istight = true; - istight&= MuonCand_ispfmuon[nMuonCand]; - istight&= (MuonCandTrack_chisq[nMuonCand]<10.); - istight&= (MuonCandTrack_nmuchits[nMuonCand]>=1); - istight&= (MuonCand_nstatseg[nMuonCand]>=2); - istight&= (MuonCand_dxy[nMuonCand]<.2); - istight&= (MuonCand_npxlhits[nMuonCand]>0); - istight&= (MuonCand_ntrklayers[nMuonCand]>5); - MuonCand_istight[nMuonCand] = istight; - } - - nMuonCand++; + if ( beamXing == 0) npv0true += npvtrue; } + + evt_.Weight = lumiWeights_.weight( npv0true ); + LogDebug( "GammaGammaLL" ) << "Passed Pileup retrieval stage"; } - - //std::cout << "Passed Muon" << std::endl; - // Get the electrons collection from the event - if (_fetchElectrons) { - iEvent.getByToken(eleToken_, eleColl); - // RECO electrons - // //FIXME FIXME - iEvent.getByLabel(InputTag("gsfElectrons"), eleCollRECO); - // iso deposits - IsoDepositVals isoVals(isoValLabel_.size()); - // New 2012 electron ID variables conversions - iEvent.getByToken(conversionsToken_, conversions_h); - - edm::Handle > loose_id_decisions; - iEvent.getByToken(eleLooseIdMapToken_, loose_id_decisions); - edm::Handle > medium_id_decisions; - iEvent.getByToken(eleMediumIdMapToken_, medium_id_decisions); - edm::Handle > tight_id_decisions; - iEvent.getByToken(eleTightIdMapToken_, tight_id_decisions); - - //for (electron=eleColl->begin(); electron!=eleColl->end() && nEleCandsize(); j++) { - const auto electron = eleColl->ptrAt(i); - - EleCand_e[nEleCand] = electron->energy(); - EleCand_et[nEleCand] = electron->et(); - EleCand_px[nEleCand] = electron->px(); - EleCand_py[nEleCand] = electron->py(); - EleCand_pz[nEleCand] = electron->pz(); - EleCand_p[nEleCand] = electron->p(); - EleCand_phi[nEleCand] = electron->phi(); - EleCand_eta[nEleCand] = electron->eta(); - EleCand_charge[nEleCand] = electron->charge(); - - EleCand_vtxx[nEleCand] = electron->vertex().x(); - EleCand_vtxy[nEleCand] = electron->vertex().y(); - EleCand_vtxz[nEleCand] = electron->vertex().z(); - - _leptonptmp->SetXYZM(electron->px(), electron->py(), electron->pz(), electron->mass()); - - if(electron->closestCtfTrackRef().isNonnull()) { // Only for PAT::Electron - EleCandTrack_p[nEleCand] = electron->closestCtfTrackRef()->p(); - EleCandTrack_pt[nEleCand] = electron->closestCtfTrackRef()->pt(); - EleCandTrack_eta[nEleCand] = electron->closestCtfTrackRef()->eta(); - EleCandTrack_phi[nEleCand] = electron->closestCtfTrackRef()->phi(); - EleCandTrack_vtxz[nEleCand] = electron->closestCtfTrackRef()->vertex().z(); - _leptonptmp->SetPtEtaPhiM(EleCandTrack_pt[nEleCand], EleCandTrack_eta[nEleCand], EleCandTrack_phi[nEleCand], electron->mass()); - } + muonsMomenta_.clear(); + electronsMomenta_.clear(); + muonTransientTracks_.clear(); + eleTransientTracks_.clear(); - electronsMomenta.insert(std::pair(nEleCand, *_leptonptmp)); - - EleCand_deltaPhi[nEleCand] = electron->deltaPhiSuperClusterTrackAtVtx(); - EleCand_deltaEta[nEleCand] = electron->deltaEtaSuperClusterTrackAtVtx(); - EleCand_HoverE[nEleCand] = electron->hcalOverEcal(); - EleCand_trackiso[nEleCand] = electron->dr03TkSumPt() / electron->et(); - EleCand_ecaliso[nEleCand] = electron->dr03EcalRecHitSumEt() / electron->et(); - EleCand_hcaliso[nEleCand] = electron->dr03HcalTowerSumEt() / electron->et(); - EleCand_sigmaIetaIeta[nEleCand] = electron->sigmaIetaIeta(); - EleCand_convDist[nEleCand] = fabs(electron->convDist()); - EleCand_convDcot[nEleCand] = fabs(electron->convDcot()); - EleCand_ecalDriven[nEleCand] = electron->ecalDrivenSeed(); - - //reco::GsfElectron* electron - EleCand_looseID[nEleCand] = (*loose_id_decisions)[electron]; - EleCand_mediumID[nEleCand] = (*medium_id_decisions)[electron]; - EleCand_tightID[nEleCand] = (*tight_id_decisions)[electron]; - - nEleCand++; - } + if ( fetchMuons_ ) fetchMuons( iEvent ); + if ( fetchElectrons_ ) fetchElectrons( iEvent ); + + newVertexInfoRetrieval( iEvent ); + + if ( !foundPairInEvent_ ) { + //LogDebug( "GammaGammaLL" ) << "No pair retrieved in event"; + return; // avoid to unpack RP/jet/MET if no dilepton candidate has been found } - delete _leptonptmp; - - nLeptonCand += (_fetchMuons) ? nMuonCand : 0; - nLeptonCand += (_fetchElectrons) ? nEleCand : 0; - - //std::cout << "Passed Electron" << std::endl; - - // Get the PFlow collection from the event - iEvent.getByToken(pflowToken_, pflowColl); - for(pflow=pflowColl->begin(); pflow!=pflowColl->end(); pflow++) { - parttype = reco::PFCandidate::ParticleType(pflow->particleId()); - if(parttype==4 && nPFPhotonCandpx(); - leadingphotpy = pflow->py(); - leadingphotpz = pflow->pz(); - leadingphotp = pflow->p(); - } - PFPhotonCand_p[nPFPhotonCand] = pflow->p(); - PFPhotonCand_px[nPFPhotonCand] = pflow->px(); - PFPhotonCand_py[nPFPhotonCand] = pflow->py(); - PFPhotonCand_pz[nPFPhotonCand] = pflow->pz(); - PFPhotonCand_pt[nPFPhotonCand] = pflow->pt(); - PFPhotonCand_eta[nPFPhotonCand] = pflow->eta(); - PFPhotonCand_phi[nPFPhotonCand] = pflow->phi(); - PFPhotonCand_drtrue[nPFPhotonCand] = -999.; - PFPhotonCand_detatrue[nPFPhotonCand] = -999.; - PFPhotonCand_dphitrue[nPFPhotonCand] = -999.; - photdr = 999.; - endphotdr = endphotdeta = endphotdphi = 999.; - if (runOnMC_) { - for (int j=0; jsize(); + if ( printCandidates_ ) + std::cout << "Event " << evt_.Run << ":" << evt_.EventNum << " has " << evt_.nPair << " leptons pair(s) candidate(s) (vertex mult. : " << evt_.nPrimVertexCand << " )" << std::endl; - if (nLeptonCand>=2) { - // Enough leptons candidates to go deeper and analyze the primary vertices - - _leptonType = new TString(); - - etind = 0; + tree_->Fill(); +} - for (vertex=vertices->begin(); vertex!=vertices->end() && vtxind > genPartColl; + iEvent.getByToken( genToken_, genPartColl ); - //(*logfile) << vertex->z() << std::endl; + for ( unsigned int i = 0; i < genPartColl->size(); ++i ) { + const edm::Ptr genPart = genPartColl->ptrAt( i ); - nLeptonsInPrimVertex = 0; - nExtraTracks = 0; - nQualityExtraTrack = 0; - foundPairOnVertex = false; - - vtx.SetPosition(vertex->x(), vertex->y(), vertex->z()); - - PrimVertexCand_id[vtxind] = vtxind; - PrimVertexCand_x[vtxind] = vtx.Position.X(); - PrimVertexCand_y[vtxind] = vtx.Position.Y(); - PrimVertexCand_z[vtxind] = vtx.Position.Z(); - PrimVertexCand_chi2[vtxind] = vertex->chi2(); - PrimVertexCand_ndof[vtxind] = vertex->ndof(); - - closesttrkid = closesthighpuritytrkid = -1; - // Loop on all the tracks matched with this vertex - reco::Vertex::trackRef_iterator _track; - for (_track=vertex->tracks_begin(); _track!=vertex->tracks_end() && etind(), *_leptonType); - if (leptonId_==-1) { // Track was not matched to any of the leptons in the collection - ExtraTrack_vtxId[etind] = vtxind; - vtxdst = sqrt(std::pow(((*_track)->vertex().x()-vtx.Position.X()),2)+ - std::pow(((*_track)->vertex().y()-vtx.Position.Y()),2)+ - std::pow(((*_track)->vertex().z()-vtx.Position.Z()),2)); - - ExtraTrack_purity[etind] = (*_track)->quality(reco::TrackBase::highPurity); - ExtraTrack_nhits[etind] = (*_track)->numberOfValidHits(); - - ExtraTrack_p[etind] = (*_track)->p(); - ExtraTrack_px[etind] = (*_track)->px(); - ExtraTrack_py[etind] = (*_track)->py(); - ExtraTrack_pz[etind] = (*_track)->pz(); - ExtraTrack_pt[etind] = (*_track)->pt(); - ExtraTrack_eta[etind] = (*_track)->eta(); - ExtraTrack_phi[etind] = (*_track)->phi(); - ExtraTrack_charge[etind] = (*_track)->charge(); - ExtraTrack_chi2[etind] = (*_track)->chi2(); - ExtraTrack_ndof[etind] = (*_track)->ndof(); - ExtraTrack_vtxdxyz[etind] = vtxdst; - ExtraTrack_vtxT[etind] = sqrt(std::pow((*_track)->vertex().x()-vtx.Position.X(),2)+ - std::pow((*_track)->vertex().y()-vtx.Position.Y(),2)); - ExtraTrack_vtxZ[etind] = fabs((*_track)->vertex().z()-vtx.Position.Z()); - ExtraTrack_x[etind] = (*_track)->vertex().x(); - ExtraTrack_y[etind] = (*_track)->vertex().y(); - ExtraTrack_z[etind] = (*_track)->vertex().z(); - - if (vtxdst<0.1) Pair_extratracks1mm[vtxind]++; - if (vtxdst<0.2) Pair_extratracks2mm[vtxind]++; - if (vtxdst<0.3) Pair_extratracks3mm[vtxind]++; - if (vtxdst<0.4) Pair_extratracks4mm[vtxind]++; - if (vtxdst<0.5) Pair_extratracks5mm[vtxind]++; - if (vtxdst<1.0) Pair_extratracks1cm[vtxind]++; - if (vtxdst<2.0) Pair_extratracks2cm[vtxind]++; - if (vtxdst<3.0) Pair_extratracks3cm[vtxind]++; - if (vtxdst<4.0) Pair_extratracks4cm[vtxind]++; - if (vtxdst<5.0) Pair_extratracks5cm[vtxind]++; - if (vtxdst<10.) Pair_extratracks10cm[vtxind]++; - if (vtxdst=3) { - nQualityExtraTrack++; - if (vtxdst " << leptonId_ << std::endl; -#endif - nLeptonsInPrimVertex++; - } - } - ClosestExtraTrack_vtxdxyz[vtxind] = closesttrkdxyz; - ClosestExtraTrack_id[vtxind] = closesttrkid; - ClosestHighPurityExtraTrack_vtxdxyz[vtxind] = closesthighpuritytrkdxyz; - ClosestHighPurityExtraTrack_id[vtxind] = closesttrkid; - - PrimVertexCand_tracks[vtxind] = vtx.nTracks; - PrimVertexCand_matchedtracks[vtxind] = vtx.nMatchedTracks; - PrimVertexCand_unmatchedtracks[vtxind] = vtx.nUnmatchedTracks; + if ( !genPart->isPromptFinalState() ) continue; - if (nLeptonsInPrimVertex<2) continue; - - // At this stage we have at least two matched leptons track on the vertex - Pair_candidates[vtxind][0] = -1; - Pair_candidates[vtxind][1] = -1; - - if (PrimVertexCand_unmatchedtracks[vtxind]>(int)maxExTrkVtx_) continue; // cut on the upper number of extra tracks - - if (_fetchElectrons && _fetchMuons) { // Looks at electron+muon - // Not enough muons or electrons candidates on the vertex - if (vtx.Electrons()==0 or vtx.Muons()==0) { -#ifdef DEBUG - std::cout << "Not enough electrons (" << vtx.Electrons() << ") or muons (" << vtx.Muons() << ") arising from the primary vertex !" << std::endl; -#endif - continue; - } - minDist = 999.; - for(unsigned int i=0; i0) { - continue; - } - foundPairOnVertex = true; - leptonsDist=sqrt(pow(MuonCand_vtxx[lep1]-EleCand_vtxx[lep2],2)+ - pow(MuonCand_vtxy[lep1]-EleCand_vtxy[lep2],2)+ - pow(MuonCand_vtxz[lep1]-EleCand_vtxz[lep2],2)); - if (leptonsDist0) { - continue; - } - foundPairOnVertex = true; - leptonsDist=sqrt(pow(EleCand_vtxx[lep1]-EleCand_vtxx[lep2],2)+ - pow(EleCand_vtxy[lep1]-EleCand_vtxy[lep2],2)+ - pow(EleCand_vtxz[lep1]-EleCand_vtxz[lep2],2)); - if (leptonsDist0) { - continue; - } - foundPairOnVertex = true; - leptonsDist=sqrt(pow(MuonCand_vtxx[lep1]-MuonCand_vtxx[lep2],2)+ - pow(MuonCand_vtxy[lep1]-MuonCand_vtxy[lep2],2)+ - pow(MuonCand_vtxz[lep1]-MuonCand_vtxz[lep2],2)); - if (leptonsDistpt() < minPtMC_ || ( minEtaMC_ != -1. && fabs( genPart->eta() ) > minEtaMC_ ) ) { + if ( fabs( genPart->pdgId() ) == 13 ) evt_.nGenMuonCandOutOfAccept++; + if ( fabs( genPart->pdgId() ) == 11 ) evt_.nGenEleCandOutOfAccept++; + if ( fabs( genPart->pdgId() ) == 22 ) evt_.nGenPhotCandOutOfAccept++; + if ( genPart->pdgId() != 2212 ) continue; // we keep the forward protons + } -#ifdef DEBUG - std::cout << "=====> did we find a pair on this vertex ? " << foundPairOnVertex << std::endl; -#endif - if (foundPairOnVertex) { - Pair_mindist[vtxind] = minDist; -#ifdef DEBUG - std::cout << "Matched muons : " << std::endl; - for (i=0; i " << vtx.MatchedMuons[i] << std::endl; - } - std::cout << "Matched electrons : " << std::endl; - for (i=0; i " << vtx.MatchedElectrons[i] << std::endl; - } -#endif - pair = l1+l2; - Pair_p[vtxind] = pair.P(); - Pair_pt[vtxind] = pair.Pt(); - Pair_mass[vtxind] = pair.M(); - Pair_phi[vtxind] = pair.Phi(); - Pair_eta[vtxind] = pair.Eta(); - dphi = fabs(l1.Phi()-l2.Phi()); - Pair_dphi[vtxind] = (dphibegin(); jet!=jetColl->end() && nJetCandenergy(); - JetCand_px[nJetCand] = jet->px(); - JetCand_py[nJetCand] = jet->py(); - JetCand_pz[nJetCand] = jet->pz(); - JetCand_phi[nJetCand] = jet->phi(); - JetCand_eta[nJetCand] = jet->eta(); - totalJetEnergy += JetCand_e[nJetCand]; - // Find kinematics quantities associated to the highest energy jet - if(JetCand_e[nJetCand]>HEJet_e) { - HEJet_e = JetCand_e[nJetCand]; - HEJet_eta = JetCand_eta[nJetCand]; - HEJet_phi = JetCand_phi[nJetCand]; + + // generated central dimuon system + if ( fabs( genPart->pdgId() ) == 11 && evt_.nGenEleCand < ggll::AnalysisEvent::MAX_GENELE ) { + evt_.GenEleCand_pt[evt_.nGenEleCand] = genPart->pt(); + evt_.GenEleCand_eta[evt_.nGenEleCand] = genPart->eta(); + evt_.GenEleCand_phi[evt_.nGenEleCand] = genPart->phi(); + evt_.GenEleCand_e[evt_.nGenEleCand] = genPart->energy(); + evt_.nGenEleCand++; } - nJetCand++; - } - HighestJet_e = HEJet_e; - HighestJet_eta = HEJet_eta; - HighestJet_phi = HEJet_phi; - SumJet_e = totalJetEnergy; - - //std::cout << "Passed Loop on jets" << std::endl; - - // Missing ET - iEvent.getByToken(metToken_, MET); - const reco::PFMETCollection* metColl = MET.product(); - met = metColl->begin(); - - Etmiss = met->et(); - Etmiss_phi = met->phi(); - Etmiss_x = met->px(); - Etmiss_y = met->py(); - Etmiss_z = met->pz(); - Etmiss_significance = met->significance(); - - //std::cout << "Passed MET" << std::endl; - - if (foundPairInEvent) { - if (printCandidates_) { - std::cout << "Event " << Run << ":" << EventNum << " has " << nCandidatesInEvent << " leptons pair(s) candidate(s) (vertex mult. : " << nPrimVertexCand << ")" << std::endl; + + if ( genPart->pdgId() == 2212 && fabs( genPart->pz() ) > 3000. ) { + // Kinematic quantities computation + // xi = fractional momentum loss + /*if ( genPart->pz() > 0. ) xi = 1.-2.*genPart->pz()/sqrts_; + else xi = 1.+2.*genPart->pz()/sqrts_; + t = -( std::pow( genPart->pt(), 2 )+std::pow( genPart->mass()*xi, 2 ) )/( 1.-xi );*/ } - tree_->Fill(); } -} + bool foundGenCandPairInEvent = false; -// ------------ method called once each job just before starting event loop ------------ -void -GammaGammaLL::beginJob() + TLorentzVector l1, l2; + // electron+muon + if ( leptonsType_ == ggll::ElectronMuon && evt_.nGenMuonCand == 1 && evt_.nGenEleCand == 1 ) { // FIXME maybe a bit tight according to the newer PU conditions? + l1.SetPtEtaPhiE( evt_.GenMuonCand_pt[0], evt_.GenMuonCand_eta[0], evt_.GenMuonCand_phi[0], evt_.GenMuonCand_e[0] ); + l2.SetPtEtaPhiE( evt_.GenEleCand_pt[0], evt_.GenEleCand_eta[0], evt_.GenEleCand_phi[0], evt_.GenEleCand_e[0] ); + foundGenCandPairInEvent = true; + } + // dielectron + else if ( leptonsType_ == ggll::DiElectron && evt_.nGenEleCand == 2 ) { // FIXME maybe a bit tight according to the newer PU conditions? + l1.SetPtEtaPhiE( evt_.GenEleCand_pt[0], evt_.GenEleCand_eta[0], evt_.GenEleCand_phi[0], evt_.GenEleCand_e[0] ); + l2.SetPtEtaPhiE( evt_.GenEleCand_pt[1], evt_.GenEleCand_eta[1], evt_.GenEleCand_phi[1], evt_.GenEleCand_e[1] ); + foundGenCandPairInEvent = true; + } + // dimuon + else if ( leptonsType_ == ggll::DiMuon && evt_.nGenMuonCand == 2 ) { // FIXME maybe a bit tight according to the newer PU conditions? + l1.SetPtEtaPhiE( evt_.GenMuonCand_pt[0], evt_.GenMuonCand_eta[0], evt_.GenMuonCand_phi[0], evt_.GenMuonCand_e[0] ); + l2.SetPtEtaPhiE( evt_.GenMuonCand_pt[1], evt_.GenMuonCand_eta[1], evt_.GenMuonCand_phi[1], evt_.GenMuonCand_e[1] ); + foundGenCandPairInEvent = true; + } + if ( foundGenCandPairInEvent ) { + const TLorentzVector pair = l1+l2; + evt_.GenPair_mass = pair.M(); + evt_.GenPair_pt = pair.Pt(); + evt_.GenPair_eta = pair.Eta(); + evt_.GenPair_phi = pair.Phi(); + + double dphi = fabs( l1.Phi()-l2.Phi() ); + // dphi lies in [-pi, pi] + while ( dphi < -M_PI ) dphi += 2.*M_PI; + while ( dphi > M_PI ) dphi -= 2.*M_PI; + evt_.GenPair_dphi = dphi; + + evt_.GenPair_dpt = fabs( l1.Pt()-l2.Pt() ); + evt_.GenPair_3Dangle = l1.Angle( l2.Vect() )/M_PI; + } +} + +void +GammaGammaLL::fetchMuons( const edm::Event& iEvent ) { - // Booking the ntuple - - tree_->Branch("Run", &Run, "Run/I"); - tree_->Branch("LumiSection", &LumiSection, "LumiSection/I"); - tree_->Branch("BX", &BX, "BX/I"); - tree_->Branch("EventNum", &EventNum, "EventNum/I"); - /*tree_->Branch("AvgInstDelLumi", &AvgInstDelLumi, "AvgInstDelLumi/D"); - tree_->Branch("BunchInstLumi", &BunchInstLumi, "BunchInstLumi[3]/D");*/ - - tree_->Branch("nHLT", &nHLT, "nHLT/I"); - tree_->Branch("HLT_Accept", HLT_Accept, "HLT_Prescl[nHLT]/I"); - tree_->Branch("HLT_Prescl", HLT_Prescl, "HLT_Prescl[nHLT]/I"); - - if (_fetchMuons) { - tree_->Branch("nMuonCand", &nMuonCand, "nMuonCand/I"); - tree_->Branch("MuonCand_px", MuonCand_px, "MuonCand_px[nMuonCand]/D"); - tree_->Branch("MuonCand_py", MuonCand_py, "MuonCand_py[nMuonCand]/D"); - tree_->Branch("MuonCand_pz", MuonCand_pz, "MuonCand_pz[nMuonCand]/D"); - tree_->Branch("MuonCand_p", MuonCand_p, "MuonCand_p[nMuonCand]/D"); - tree_->Branch("MuonCand_pt", MuonCand_pt, "MuonCand_pt[nMuonCand]/D"); - tree_->Branch("MuonCand_eta", MuonCand_eta, "MuonCand_eta[nMuonCand]/D"); - tree_->Branch("MuonCand_phi", MuonCand_phi, "MuonCand_phi[nMuonCand]/D"); - tree_->Branch("MuonCand_charge", MuonCand_charge, "MuonCand_charge[nMuonCand]/I"); - tree_->Branch("MuonCand_vtxx", MuonCand_vtxx, "MuonCand_vtxx[nMuonCand]/D"); - tree_->Branch("MuonCand_vtxy", MuonCand_vtxy, "MuonCand_vtxy[nMuonCand]/D"); - tree_->Branch("MuonCand_vtxz", MuonCand_vtxz, "MuonCand_vtxz[nMuonCand]/D"); - tree_->Branch("MuonCand_dxy", MuonCand_dxy, "MuonCand_dxy[nMuonCand]/D"); - tree_->Branch("MuonCand_dz", MuonCand_dz, "MuonCand_dz[nMuonCand]/D"); - tree_->Branch("MuonCand_nstatseg", MuonCand_nstatseg, "MuonCand_nstatseg[nMuonCand]/I"); - tree_->Branch("MuonCand_ntrklayers", MuonCand_ntrklayers, "MuonCand_ntrklayers[nMuonCand]/I"); - tree_->Branch("MuonCand_npxlhits", MuonCand_npxlhits, "MuonCand_npxlhits[nMuonCand]/I"); - tree_->Branch("MuonCand_isglobal", MuonCand_isglobal, "MuonCand_isglobal[nMuonCand]/I"); - tree_->Branch("MuonCand_istracker", MuonCand_istracker, "MuonCand_istracker[nMuonCand]/I"); - tree_->Branch("MuonCand_isstandalone", MuonCand_isstandalone, "MuonCand_isstandalone[nMuonCand]/I"); - tree_->Branch("MuonCand_ispfmuon", MuonCand_ispfmuon, "MuonCand_ispfmuon[nMuonCand]/I"); - tree_->Branch("MuonCand_istight", MuonCand_istight, "MuonCand_istight[nMuonCand]/I"); - tree_->Branch("MuonCandTrack_nmuchits", MuonCandTrack_nmuchits, "MuonCandTrack_nmuchits[nMuonCand]/I"); - tree_->Branch("MuonCandTrack_chisq", MuonCandTrack_chisq, "MuonCandTrack_chisq[nMuonCand]/D"); - if (runOnMC_) { - tree_->Branch("nGenMuonCand", &nGenMuonCand, "nGenMuonCand/I"); - tree_->Branch("nGenMuonCandOutOfAccept", &nGenMuonCandOutOfAccept, "nGenMuonCandOutOfAccept/I"); - tree_->Branch("GenMuonCand_p", GenMuonCand_p, "GenMuonCand_p[nGenMuonCand]/D"); - tree_->Branch("GenMuonCand_px", GenMuonCand_px, "GenMuonCand_px[nGenMuonCand]/D"); - tree_->Branch("GenMuonCand_py", GenMuonCand_py, "GenMuonCand_py[nGenMuonCand]/D"); - tree_->Branch("GenMuonCand_pz", GenMuonCand_pz, "GenMuonCand_pz[nGenMuonCand]/D"); - tree_->Branch("GenMuonCand_pt", GenMuonCand_pt, "GenMuonCand_pt[nGenMuonCand]/D"); - tree_->Branch("GenMuonCand_eta", GenMuonCand_eta, "GenMuonCand_eta[nGenMuonCand]/D"); - tree_->Branch("GenMuonCand_phi", GenMuonCand_phi, "GenMuonCand_phi[nGenMuonCand]/D"); + // Get the muons collection from the event + // PAT muons + edm::Handle > muonColl; + edm::View::const_iterator muon; + + iEvent.getByToken( muonToken_, muonColl ); + + for ( unsigned int i = 0; i < muonColl->size() && evt_.nMuonCand < ggll::AnalysisEvent::MAX_MUONS; ++i ) { + const edm::Ptr muon = muonColl->ptrAt( i); + + // JH + if( muon->pt() < 20) continue; + if( muon->isGlobalMuon() == 0 || muon->isTrackerMuon() == 0) continue; + + evt_.MuonCand_pt[evt_.nMuonCand] = muon->pt(); + evt_.MuonCand_eta[evt_.nMuonCand] = muon->eta(); + evt_.MuonCand_phi[evt_.nMuonCand] = muon->phi(); + evt_.MuonCand_e[evt_.nMuonCand] = muon->energy(); + evt_.MuonCand_charge[evt_.nMuonCand] = muon->charge(); + evt_.MuonCand_dxy[evt_.nMuonCand] = muon->dB(); + evt_.MuonCand_nstatseg[evt_.nMuonCand] = muon->numberOfMatchedStations(); + + evt_.MuonCand_vtxx[evt_.nMuonCand] = muon->vertex().x(); + evt_.MuonCand_vtxy[evt_.nMuonCand] = muon->vertex().y(); + evt_.MuonCand_vtxz[evt_.nMuonCand] = muon->vertex().z(); + + evt_.MuonCand_isglobal[evt_.nMuonCand] = muon->isGlobalMuon(); + evt_.MuonCand_istracker[evt_.nMuonCand] = muon->isTrackerMuon(); + evt_.MuonCand_isstandalone[evt_.nMuonCand] = muon->isStandAloneMuon(); + evt_.MuonCand_ispfmuon[evt_.nMuonCand] = muon->isPFMuon(); + + TLorentzVector leptonptmp; + leptonptmp.SetPtEtaPhiM( muon->pt(), muon->eta(), muon->phi(), muon->mass() ); + + if ( evt_.MuonCand_istracker[evt_.nMuonCand] ) { + evt_.MuonCand_npxlhits[evt_.nMuonCand] = muon->innerTrack()->hitPattern().numberOfValidPixelHits(); + evt_.MuonCand_ntrklayers[evt_.nMuonCand] = muon->innerTrack()->hitPattern().trackerLayersWithMeasurement(); + leptonptmp.SetPtEtaPhiM( muon->innerTrack()->pt(), muon->innerTrack()->eta(), muon->innerTrack()->phi(), muon->mass() ); } - } - - if (_fetchElectrons) { - tree_->Branch("nEleCand", &nEleCand, "nEleCand/I"); - tree_->Branch("EleCand_px", EleCand_px, "EleCand_px[nEleCand]/D"); - tree_->Branch("EleCand_py", EleCand_py, "EleCand_py[nEleCand]/D"); - tree_->Branch("EleCand_pz", EleCand_pz, "EleCand_pz[nEleCand]/D"); - tree_->Branch("EleCand_p", EleCand_p, "EleCand_p[nEleCand]/D"); - tree_->Branch("EleCand_e", EleCand_e, "EleCand_e[nEleCand]/D"); - tree_->Branch("EleCand_et", EleCand_et, "EleCand_et[nEleCand]/D"); - tree_->Branch("EleCand_eta", EleCand_eta, "EleCand_eta[nEleCand]/D"); - tree_->Branch("EleCand_phi", EleCand_phi, "EleCand_phi[nEleCand]/D"); - tree_->Branch("EleCand_charge", EleCand_charge, "EleCand_charge[nEleCand]/I"); - tree_->Branch("EleCand_vtxx", EleCand_vtxx, "EleCand_vtxx[nEleCand]/D"); - tree_->Branch("EleCand_vtxy", EleCand_vtxy, "EleCand_vtxy[nEleCand]/D"); - tree_->Branch("EleCand_vtxz", EleCand_vtxz, "EleCand_vtxz[nEleCand]/D"); - tree_->Branch("EleCandTrack_p", EleCandTrack_p, "EleCandTrack_p[nEleCand]/D"); - tree_->Branch("EleCandTrack_pt", EleCandTrack_pt, "EleCandTrack_pt[nEleCand]/D"); - tree_->Branch("EleCandTrack_eta", EleCandTrack_eta, "EleCandTrack_eta[nEleCand]/D"); - tree_->Branch("EleCandTrack_phi", EleCandTrack_phi, "EleCandTrack_phi[nEleCand]/D"); - tree_->Branch("EleCandTrack_vtxz", EleCandTrack_vtxz, "EleCandTrack_vtxz[nEleCand]/D"); - tree_->Branch("EleCand_deltaPhi", EleCand_deltaPhi, "EleCand_deltaPhi[nEleCand]/D"); - tree_->Branch("EleCand_deltaEta", EleCand_deltaEta, "EleCand_deltaEta[nEleCand]/D"); - tree_->Branch("EleCand_HoverE", EleCand_HoverE, "EleCand_HoverE[nEleCand]/D"); - tree_->Branch("EleCand_trackiso", EleCand_trackiso, "EleCand_trackiso[nEleCand]/D"); - tree_->Branch("EleCand_ecaliso", EleCand_ecaliso," EleCand_ecaliso[nEleCand]/D"); - tree_->Branch("EleCand_hcaliso", EleCand_hcaliso," EleCand_hcaliso[nEleCand]/D"); - tree_->Branch("EleCand_sigmaIetaIeta", EleCand_sigmaIetaIeta, "EleCand_sigmaIetaIeta[nEleCand]/D"); - tree_->Branch("EleCand_convDist", EleCand_convDist, "EleCand_convDist[nEleCand]/D"); - tree_->Branch("EleCand_convDcot", EleCand_convDcot, "EleCand_convDcot[nEleCand]/D"); - tree_->Branch("EleCand_ecalDriven", EleCand_ecalDriven, "EleCand_ecalDriven[nEleCand]/D"); - tree_->Branch("EleCand_mediumID", EleCand_mediumID, "EleCand_mediumID[nEleCand]/I"); - tree_->Branch("EleCand_looseID", EleCand_looseID, "EleCand_looseID[nEleCand]/I"); - tree_->Branch("EleCand_tightID", EleCand_tightID, "EleCand_tightID[nEleCand]/I"); - /*tree_->Branch("EleCand_looseid", EleCand_looseid,"EleCand_looseid[nEleCand]/I"); - tree_->Branch("EleCand_likelihoodid", EleCand_likelihoodid,"EleCand_likelihoodid[nEleCand]/D"); - tree_->Branch("EleCand_robustid", EleCand_robustid,"EleCand_robustid[nEleCand]/I");*/ - if (runOnMC_) { - tree_->Branch("nGenEleCand", &nGenEleCand, "nGenEleCand/I"); - tree_->Branch("nGenEleCandOutOfAccept", &nGenEleCandOutOfAccept, "nGenEleCandOutOfAccept/I"); - tree_->Branch("GenEleCand_p", GenEleCand_p, "GenEleCand_p[nGenEleCand]/D"); - tree_->Branch("GenEleCand_px", GenEleCand_px, "GenEleCand_px[nGenEleCand]/D"); - tree_->Branch("GenEleCand_py", GenEleCand_py, "GenEleCand_py[nGenEleCand]/D"); - tree_->Branch("GenEleCand_pz", GenEleCand_pz, "GenEleCand_pz[nGenEleCand]/D"); - tree_->Branch("GenEleCand_pt", GenEleCand_pt, "GenEleCand_pt[nGenEleCand]/D"); - tree_->Branch("GenEleCand_eta", GenEleCand_eta, "GenEleCand_eta[nGenEleCand]/D"); - tree_->Branch("GenEleCand_phi", GenEleCand_phi, "GenEleCand_phi[nGenEleCand]/D"); + muonsMomenta_.insert( std::pair( evt_.nMuonCand, leptonptmp ) ); + + if ( evt_.MuonCand_isglobal[evt_.nMuonCand] && evt_.MuonCand_istracker[evt_.nMuonCand] ) { + evt_.MuonCand_innerTrackPt[evt_.nMuonCand] = muon->innerTrack()->pt(); + evt_.MuonCand_innerTrackEta[evt_.nMuonCand] = muon->innerTrack()->eta(); + evt_.MuonCand_innerTrackPhi[evt_.nMuonCand] = muon->innerTrack()->phi(); + evt_.MuonCand_innerTrackVtxz[evt_.nMuonCand] = muon->innerTrack()->vertex().z(); + evt_.MuonCandTrack_nmuchits[evt_.nMuonCand] = muon->globalTrack()->hitPattern().numberOfValidMuonHits(); + evt_.MuonCandTrack_chisq[evt_.nMuonCand] = muon->globalTrack()->normalizedChi2(); + const bool istight = ( evt_.MuonCand_ispfmuon[evt_.nMuonCand] + && ( evt_.MuonCandTrack_chisq[evt_.nMuonCand] < 10. ) + && ( evt_.MuonCandTrack_nmuchits[evt_.nMuonCand] >= 1 ) + && ( evt_.MuonCand_nstatseg[evt_.nMuonCand] >= 2 ) + && ( evt_.MuonCand_dxy[evt_.nMuonCand] < 0.2 ) + && ( evt_.MuonCand_npxlhits[evt_.nMuonCand] > 0 ) + && ( evt_.MuonCand_ntrklayers[evt_.nMuonCand] > 5 ) ); + evt_.MuonCand_istight[evt_.nMuonCand] = istight; + + muonTransientTracks_[evt_.nMuonCand] = KalVtx_->build( *muon->innerTrack() ); } + + evt_.nMuonCand++; } - tree_->Branch("nPFPhotonCand", &nPFPhotonCand, "nPFPhotonCand/I"); - tree_->Branch("PFPhotonCand_pt", PFPhotonCand_pt, "PFPhotonCand_pt[nPFPhotonCand]/D"); - tree_->Branch("PFPhotonCand_eta", PFPhotonCand_eta, "PFPhotonCand_eta[nPFPhotonCand]/D"); - tree_->Branch("PFPhotonCand_phi", PFPhotonCand_phi, "PFPhotonCand_phi[nPFPhotonCand]/D"); - tree_->Branch("PFPhotonCand_drtrue", PFPhotonCand_drtrue, "PFPhotonCand_drtrue[nPFPhotonCand]/D"); - tree_->Branch("PFPhotonCand_detatrue", PFPhotonCand_detatrue, "PFPhotonCand_detatrue[nPFPhotonCand]/D"); - tree_->Branch("PFPhotonCand_dphitrue", PFPhotonCand_dphitrue, "PFPhotonCand_dphitrue[nPFPhotonCand]/D"); - if (runOnMC_) { - tree_->Branch("nGenPhotCand", &nGenPhotCand, "nGenPhotCand/I"); - tree_->Branch("nGenPhotCandOutOfAccept", &nGenPhotCandOutOfAccept, "nGenPhotCandOutOfAccept/I"); - tree_->Branch("GenPhotCand_e", GenPhotCand_e, "GenPhotCand_e[nGenPhotCand]/D"); - tree_->Branch("GenPhotCand_p", GenPhotCand_p, "GenPhotCand_p[nGenPhotCand]/D"); - tree_->Branch("GenPhotCand_pt", GenPhotCand_pt, "GenPhotCand_pt[nGenPhotCand]/D"); - tree_->Branch("GenPhotCand_eta", GenPhotCand_eta, "GenPhotCand_eta[nGenPhotCand]/D"); - tree_->Branch("GenPhotCand_phi", GenPhotCand_phi, "GenPhotCand_phi[nGenPhotCand]/D"); - tree_->Branch("nGenProtCand", &nGenProtCand, "nGenProtCand/I"); - tree_->Branch("GenProtCand_p", GenProtCand_p, "GenProtCand_p[nGenProtCand]/D"); - tree_->Branch("GenProtCand_px", GenProtCand_px, "GenProtCand_px[nGenProtCand]/D"); - tree_->Branch("GenProtCand_py", GenProtCand_py, "GenProtCand_py[nGenProtCand]/D"); - tree_->Branch("GenProtCand_pz", GenProtCand_pz, "GenProtCand_pz[nGenProtCand]/D"); - tree_->Branch("GenProtCand_pt", GenProtCand_pt, "GenProtCand_pt[nGenProtCand]/D"); - tree_->Branch("GenProtCand_eta", GenProtCand_eta, "GenProtCand_eta[nGenProtCand]/D"); - tree_->Branch("GenProtCand_phi", GenProtCand_phi, "GenProtCand_phi[nGenProtCand]/D"); - tree_->Branch("GenProtCand_status", GenProtCand_status, "GenProtCand_status[nGenProtCand]/I"); + LogDebug( "GammaGammaLL" ) << "Passed Muon retrieval stage. Got " << evt_.nMuonCand << " muon(s)"; +} + +void +GammaGammaLL::fetchElectrons( const edm::Event& iEvent ) +{ + // Get the electrons collection from the event + edm::Handle > eleColl; + iEvent.getByToken( eleToken_, eleColl ); + + /*edm::Handle > medium_id_decisions, tight_id_decisions; + iEvent.getByToken( eleMediumIdMapToken_, medium_id_decisions ); + iEvent.getByToken( eleTightIdMapToken_, tight_id_decisions );*/ + + edm::Handle rhoJECJets; + iEvent.getByToken( fixedGridRhoFastjetAllToken_, rhoJECJets );//kt6PFJets + + for ( unsigned int i = 0; i < eleColl->size(); ++i ) { + const edm::Ptr electron = eleColl->ptrAt( i ); + + evt_.EleCand_et[evt_.nEleCand] = electron->et(); + evt_.EleCand_eta[evt_.nEleCand] = electron->eta(); + evt_.EleCand_phi[evt_.nEleCand] = electron->phi(); + evt_.EleCand_e[evt_.nEleCand] = electron->energy(); + evt_.EleCand_charge[evt_.nEleCand] = electron->charge(); + + evt_.EleCand_vtxx[evt_.nEleCand] = electron->vertex().x(); + evt_.EleCand_vtxy[evt_.nEleCand] = electron->vertex().y(); + evt_.EleCand_vtxz[evt_.nEleCand] = electron->vertex().z(); + + TLorentzVector leptonptmp; + leptonptmp.SetPtEtaPhiM( electron->et(), electron->eta(), electron->phi(), electron->mass() ); + + if ( electron->closestCtfTrackRef().isNonnull() ) { // Only for pat::Electron + evt_.EleCand_innerTrackPt[evt_.nEleCand] = electron->closestCtfTrackRef()->pt(); + evt_.EleCand_innerTrackEta[evt_.nEleCand] = electron->closestCtfTrackRef()->eta(); + evt_.EleCand_innerTrackPhi[evt_.nEleCand] = electron->closestCtfTrackRef()->phi(); + evt_.EleCand_innerTrackVtxz[evt_.nEleCand] = electron->closestCtfTrackRef()->vertex().z(); + leptonptmp.SetPtEtaPhiM( evt_.EleCand_innerTrackPt[evt_.nEleCand], evt_.EleCand_innerTrackEta[evt_.nEleCand], evt_.EleCand_innerTrackPhi[evt_.nEleCand], electron->mass() ); + //eleTransientTrack[evt_.nEleCand] = KalVtx_->build( *electron->closestCtfTrackRef() ); + } + eleTransientTracks_[evt_.nEleCand] = KalVtx_->build( *electron->gsfTrack() ); + + electronsMomenta_.insert( std::pair( evt_.nEleCand, leptonptmp ) ); + + evt_.EleCand_deltaPhi[evt_.nEleCand] = electron->deltaPhiSuperClusterTrackAtVtx(); + evt_.EleCand_deltaEta[evt_.nEleCand] = electron->deltaEtaSuperClusterTrackAtVtx(); + evt_.EleCand_HoverE[evt_.nEleCand] = electron->hcalOverEcal(); + evt_.EleCand_trackiso[evt_.nEleCand] = electron->dr03TkSumPt() / electron->et(); + evt_.EleCand_ecaliso[evt_.nEleCand] = electron->dr03EcalRecHitSumEt() / electron->et(); + evt_.EleCand_hcaliso[evt_.nEleCand] = electron->dr03HcalTowerSumEt() / electron->et(); + evt_.EleCand_sigmaIetaIeta[evt_.nEleCand] = electron->sigmaIetaIeta(); + evt_.EleCand_convDist[evt_.nEleCand] = fabs( electron->convDist() ); + evt_.EleCand_convDcot[evt_.nEleCand] = fabs( electron->convDcot() ); + evt_.EleCand_ecalDriven[evt_.nEleCand] = electron->ecalDrivenSeed(); + + const std::vector ids = electron->electronIDs(); + for ( unsigned int j = 0; j < ids.size(); ++j ) { + pat::Electron::IdPair idp = ids.at( j ); + //FIXME make me private attributes + if ( eleMediumIdLabel_.find( idp.first ) != std::string::npos ) evt_.EleCand_mediumID[evt_.nEleCand] = idp.second; + if ( eleTightIdLabel_.find( idp.first ) != std::string::npos ) evt_.EleCand_tightID[evt_.nEleCand] = idp.second; + } + + //edm::RefToBase electronRef( eleColl->refAt( i ) ); + //evt_.EleCand_mediumID[evt_.nEleCand] = medium_id_decisions->operator[]( electronRef ), + //evt_.EleCand_tightID[evt_.nEleCand] = tight_id_decisions->operator[]( electronRef ), + + evt_.nEleCand++; } - - // Primary vertices' information - tree_->Branch("nPrimVertexCand", &nPrimVertexCand, "nPrimVertexCand/I"); - tree_->Branch("nFilteredPrimVertexCand", &nFilteredPrimVertexCand, "nPrimVertexCand/I"); - tree_->Branch("PrimVertexCand_id", PrimVertexCand_id, "PrimVertexCand_id[nPrimVertexCand]/I"); - tree_->Branch("PrimVertexCand_hasdil", PrimVertexCand_hasdil, "PrimVertexCand_hasdil[nPrimVertexCand]/I"); - tree_->Branch("PrimVertexCand_x", PrimVertexCand_x, "PrimVertexCand_x[nPrimVertexCand]/D"); - tree_->Branch("PrimVertexCand_y", PrimVertexCand_y, "PrimVertexCand_y[nPrimVertexCand]/D"); - tree_->Branch("PrimVertexCand_z", PrimVertexCand_z, "PrimVertexCand_z[nPrimVertexCand]/D"); - tree_->Branch("PrimVertexCand_tracks", PrimVertexCand_tracks, "PrimVertexCand_tracks[nPrimVertexCand]/I"); - tree_->Branch("PrimVertexCand_matchedtracks", PrimVertexCand_matchedtracks, "PrimVertexCand_matchedtracks[nPrimVertexCand]/I"); - tree_->Branch("PrimVertexCand_unmatchedtracks", PrimVertexCand_unmatchedtracks, "PrimVertexCand_unmatchedtracks[nPrimVertexCand]/I"); - tree_->Branch("PrimVertexCand_chi2", PrimVertexCand_chi2, "PrimVertexCand_chi2[nPrimVertexCand]/D"); - tree_->Branch("PrimVertexCand_ndof", PrimVertexCand_ndof, "PrimVertexCand_ndof[nPrimVertexCand]/I"); - - // Lepton pairs' information - tree_->Branch("Pair_candidates", Pair_candidates, "Pair_candidates[nPrimVertexCand][2]/I"); - tree_->Branch("Pair_mindist", Pair_mindist, "Pair_mindist[nPrimVertexCand]/D"); - tree_->Branch("Pair_p", Pair_p, "Pair_p[nPrimVertexCand]/D"); - tree_->Branch("Pair_pt", Pair_pt, "Pair_pt[nPrimVertexCand]/D"); - tree_->Branch("Pair_dpt", Pair_dpt, "Pair_dpt[nPrimVertexCand]/D"); - tree_->Branch("Pair_mass", Pair_mass, "Pair_mass[nPrimVertexCand]/D"); - tree_->Branch("Pair_eta", Pair_eta, "Pair_eta[nPrimVertexCand]/D"); - tree_->Branch("Pair_phi", Pair_phi, "Pair_phi[nPrimVertexCand]/D"); - tree_->Branch("Pair_dphi", Pair_dphi, "Pair_dphi[nPrimVertexCand]/D"); - tree_->Branch("Pair_3Dangle", Pair_3Dangle, "Pair_3Dangle[nPrimVertexCand]/D"); - tree_->Branch("Pair_extratracks1mm", Pair_extratracks1mm, "Pair_extratracks1mm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks2mm", Pair_extratracks2mm, "Pair_extratracks2mm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks3mm", Pair_extratracks3mm, "Pair_extratracks3mm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks4mm", Pair_extratracks4mm, "Pair_extratracks4mm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks5mm", Pair_extratracks5mm, "Pair_extratracks5mm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks1cm", Pair_extratracks1cm, "Pair_extratracks1cm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks2cm", Pair_extratracks2cm, "Pair_extratracks2cm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks3cm", Pair_extratracks3cm, "Pair_extratracks3cm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks4cm", Pair_extratracks4cm, "Pair_extratracks4cm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks5cm", Pair_extratracks5cm, "Pair_extratracks5cm[nPrimVertexCand]/I"); - tree_->Branch("Pair_extratracks10cm", Pair_extratracks10cm, "Pair_extratracks10cm[nPrimVertexCand]/I"); - tree_->Branch("PairGamma_mass", PairGamma_mass, "PairGamma_mass[nPrimVertexCand][nPFPhotonCand]/D"); - if (runOnMC_) { - tree_->Branch("GenPair_p", &GenPair_p, "GenPair_p/D"); - tree_->Branch("GenPair_pt", &GenPair_pt, "GenPair_pt/D"); - tree_->Branch("GenPair_dpt", &GenPair_dpt, "GenPair_dpt/D"); - tree_->Branch("GenPair_mass", &GenPair_mass, "GenPair_mass/D"); - tree_->Branch("GenPair_eta", &GenPair_eta, "GenPair_eta/D"); - tree_->Branch("GenPair_phi", &GenPair_phi, "GenPair_phi/D"); - tree_->Branch("GenPair_dphi", &GenPair_dphi, "GenPair_dphi/D"); - tree_->Branch("GenPair_3Dangle", &GenPair_3Dangle, "GenPair_3Dangle[nPrimVertexCand]/D"); - tree_->Branch("HPS_acc420b1", &HPS_acc420b1, "HPS_acc420b1/D"); - tree_->Branch("HPS_acc220b1", &HPS_acc220b1, "HPS_acc220b1/D"); - tree_->Branch("HPS_acc420and220b1", &HPS_acc420and220b1, "HPS_acc420and220b1/D"); - tree_->Branch("HPS_acc420or220b1", &HPS_acc420or220b1, "HPS_acc420or220b1/D"); - tree_->Branch("HPS_acc420b2", &HPS_acc420b2, "HPS_acc420b2/D"); - tree_->Branch("HPS_acc220b2", &HPS_acc220b2, "HPS_acc220b2/D"); - tree_->Branch("HPS_acc420and220b2", &HPS_acc420and220b2, "HPS_acc420and220b2/D"); - tree_->Branch("HPS_acc420or220b2", &HPS_acc420or220b2, "HPS_acc420or220b2/D"); + LogDebug( "GammaGammaLL" ) << "Passed Electron retrieval stage. Got " << evt_.nEleCand << " electron(s)"; +} + +void +GammaGammaLL::fetchProtons( const edm::Event& iEvent ) +{ + // Forward proton tracks + edm::Handle > ppslocaltracks; + iEvent.getByToken( ppsLocalTrackToken_, ppslocaltracks ); + + evt_.nLocalProtCand = 0; + for ( const auto trk : *ppslocaltracks ) { + const CTPPSDetId det_id( trk.getRPId() ); + if ( evt_.nLocalProtCand == ggll::AnalysisEvent::MAX_LOCALPCAND-1 ) + throw cms::Exception( "GammaGammaLL" ) << "maximum number of local tracks in RPs is reached!\n" + << "increase MAX_LOCALPCAND=" << ggll::AnalysisEvent::MAX_LOCALPCAND << " in GammaGammaLL.cc"; + + // transform the raw, 32-bit unsigned integer detId into the TOTEM "decimal" notation + const unsigned int raw_id = 100*det_id.arm()+10*det_id.station()+det_id.rp(); + + evt_.LocalProtCand_x[evt_.nLocalProtCand] = ( trk.getX() )/1.e3; + evt_.LocalProtCand_y[evt_.nLocalProtCand] = ( trk.getY() )/1.e3; + evt_.LocalProtCand_xSigma[evt_.nLocalProtCand] = ( trk.getXUnc() )/1.e3; + evt_.LocalProtCand_ySigma[evt_.nLocalProtCand] = ( trk.getYUnc() )/1.e3; + evt_.LocalProtCand_arm[evt_.nLocalProtCand] = det_id.arm(); + evt_.LocalProtCand_station[evt_.nLocalProtCand] = det_id.station(); + evt_.LocalProtCand_pot[evt_.nLocalProtCand] = det_id.rp(); + evt_.LocalProtCand_rpid[evt_.nLocalProtCand] = raw_id; + evt_.nLocalProtCand++; + LogDebug( "GammaGammaLL" ) << "Proton track candidate with origin: ( " << trk.getX() << ", " << trk.getY() << " ) extracted!"; } - // Extra tracks on vertex's information - tree_->Branch("nExtraTracks", &nExtraTracks, "nExtraTracks/I"); - tree_->Branch("ExtraTrack_vtxId", ExtraTrack_vtxId, "ExtraTrack_vtxId[nExtraTracks]/I"); - tree_->Branch("ExtraTrack_purity", ExtraTrack_purity, "ExtraTrack_purity[nExtraTracks]/I"); - tree_->Branch("ExtraTrack_nhits", ExtraTrack_nhits, "ExtraTrack_nhits[nExtraTracks]/I"); - tree_->Branch("ExtraTrack_charge", ExtraTrack_charge, "ExtraTrack_charge[nExtraTracks]/I"); - tree_->Branch("ExtraTrack_ndof", ExtraTrack_ndof, "ExtraTrack_ndof[nExtraTracks]/I"); - tree_->Branch("ExtraTrack_p", ExtraTrack_p, "ExtraTrack_p[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_pt", ExtraTrack_pt, "ExtraTrack_pt[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_px", ExtraTrack_px, "ExtraTrack_px[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_py", ExtraTrack_py, "ExtraTrack_py[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_pz", ExtraTrack_pz, "ExtraTrack_pz[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_eta", ExtraTrack_eta, "ExtraTrack_eta[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_phi", ExtraTrack_phi, "ExtraTrack_phi[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_chi2", ExtraTrack_chi2, "ExtraTrack_chi2[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_vtxdxyz", ExtraTrack_vtxdxyz, "ExtraTrack_vtxdxyz[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_vtxT", ExtraTrack_vtxT, "ExtraTrack_vtxT[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_vtxZ", ExtraTrack_vtxZ, "ExtraTrack_vtxZ[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_x", ExtraTrack_x, "ExtraTrack_x[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_y", ExtraTrack_y, "ExtraTrack_y[nExtraTracks]/D"); - tree_->Branch("ExtraTrack_z", ExtraTrack_z, "ExtraTrack_z[nExtraTracks]/D"); - tree_->Branch("nQualityExtraTrack", &nQualityExtraTrack, "nQualityExtraTrack/I"); - tree_->Branch("ClosestExtraTrack_vtxdxyz",ClosestExtraTrack_vtxdxyz,"ClosestExtraTrack_vtxdxyz[nPrimVertexCand]/D"); - tree_->Branch("ClosestExtraTrack_id",ClosestExtraTrack_id,"ClosestExtraTrack_id[nPrimVertexCand]/I"); - tree_->Branch("ClosestHighPurityExtraTrack_vtxdxyz",ClosestHighPurityExtraTrack_vtxdxyz,"ClosestHighPurityExtraTrack_vtxdxyz[nPrimVertexCand]/D"); - tree_->Branch("ClosestHighPurityExtraTrack_id",ClosestHighPurityExtraTrack_id,"ClosestHighPurityExtraTrack_id[nPrimVertexCand]/I"); - - // Jets/MET information - tree_->Branch("nJetCand", &nJetCand, "nJetCand/I"); - tree_->Branch("JetCand_px", JetCand_px, "JetCand_px[nJetCand]/D"); - tree_->Branch("JetCand_py", JetCand_py, "JetCand_py[nJetCand]/D"); - tree_->Branch("JetCand_pz", JetCand_pz, "JetCand_pz[nJetCand]/D"); - tree_->Branch("JetCand_e", JetCand_e, "JetCand_e[nJetCand]/D"); - tree_->Branch("JetCand_eta", JetCand_eta, "JetCand_eta[nJetCand]/D"); - tree_->Branch("JetCand_phi", JetCand_phi, "JetCand_phi[nJetCand]/D"); - tree_->Branch("HighestJet_e", &HighestJet_e, "HighestJet_e/D"); - tree_->Branch("HighestJet_eta", &HighestJet_eta, "HighestJet_eta/D"); - tree_->Branch("HighestJet_phi", &HighestJet_phi, "HighestJet_phi/D"); - tree_->Branch("SumJet_e", &SumJet_e, "SumJet_e/D"); - tree_->Branch("Etmiss", &Etmiss, "Etmiss/D"); - tree_->Branch("Etmiss_phi", &Etmiss_phi, "Etmiss_phi/D"); - tree_->Branch("Etmiss_x", &Etmiss_x, "Etmiss_x/D"); - tree_->Branch("Etmiss_y", &Etmiss_y, "Etmiss_y/D"); - tree_->Branch("Etmiss_z", &Etmiss_z, "Etmiss_z/D"); - tree_->Branch("Etmiss_significance", &Etmiss_significance, "Etmiss_significance/D"); - - // Pileup reweighting - tree_->Branch("nTruePUforPUWeight",&nTruePUforPUWeight,"nTruePUforPUWeight/I"); - tree_->Branch("nTruePUafterPUWeight",&nTruePUafterPUWeight,"nTruePUafterPUWeight/D"); - tree_->Branch("nTruePUforPUWeightBXM1", &nTruePUforPUWeightBXM1, "nTruePUforPUWeightBXM1/I"); - tree_->Branch("nTruePUafterPUWeightBXM1", &nTruePUafterPUWeightBXM1, "nTruePUafterPUWeightBXM1/D"); - tree_->Branch("nTruePUforPUWeightBXP1", &nTruePUforPUWeightBXP1, "nTruePUforPUWeightBXP1/I"); - tree_->Branch("nTruePUafterPUWeightBXP1", &nTruePUafterPUWeightBXP1, "nTruePUafterPUWeightBXP1/D"); - tree_->Branch("nTruePUforPUWeightBX0", &nTruePUforPUWeightBX0, "nTruePUforPUWeightBX0/I"); - tree_->Branch("nTruePUafterPUWeightBX0", &nTruePUafterPUWeightBX0, "nTruePUafterPUWeightBX0/D"); - tree_->Branch("Weight", &Weight, "Weight/D"); - tree_->Branch("PUWeightTrue", &PUWeightTrue, "PUWeightTrue/D"); - - nCandidates = 0; + LogDebug( "GammaGammaLL" ) << "Passed TOTEM RP info retrieval stage. Got " << evt_.nLocalProtCand << " local track(s)"; + + // Full reco protons + edm::Handle> recoProtons; + iEvent.getByToken(recoProtonsToken_, recoProtons); + + int ismultirp = -999; + unsigned int decRPId = -999; + unsigned int armId = -999; + float th_y = -999; + float th_x = -999; + float t = -999; + float xi = -999; + + + evt_.nRecoProtCand = 0; + for (const auto & proton : *recoProtons) + { + if (proton.valid()) + { + th_y = (proton.direction().y()) / (proton.direction().mag()); + th_x = (proton.direction().x()) / (proton.direction().mag()); + xi = proton.xi(); + + // t + const double m = 0.938; // GeV + const double p = 6500.; // GeV + + float t0 = 2.*m*m + 2.*p*p*(1.-xi) - 2.*sqrt( (m*m + p*p) * (m*m + p*p*(1.-xi)*(1.-xi)) ); + float th = sqrt(th_x * th_x + th_y * th_y); + float S = sin(th/2.); + t = t0 - 4. * p*p * (1.-xi) * S*S; + + if (proton.method == reco::ProtonTrack::rmSingleRP) + { + CTPPSDetId rpId(* proton.contributingRPIds.begin()); + decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + ismultirp = 0; + } + if (proton.method == reco::ProtonTrack::rmMultiRP) + { + CTPPSDetId rpId(* proton.contributingRPIds.begin()); + armId = rpId.arm(); + ismultirp = 1; + } + + evt_.ProtCand_xi[evt_.nRecoProtCand] = xi; + evt_.ProtCand_t[evt_.nRecoProtCand] = t; + evt_.ProtCand_ThX[evt_.nRecoProtCand] = th_x; + evt_.ProtCand_ThY[evt_.nRecoProtCand] = th_y; + evt_.ProtCand_rpid[evt_.nRecoProtCand] = decRPId; + evt_.ProtCand_arm[evt_.nRecoProtCand] = armId; + evt_.ProtCand_ismultirp[evt_.nRecoProtCand] = ismultirp; + evt_.nRecoProtCand++; + } + } + } -// ------------ method called once each job just after ending the event loop ------------ -void -GammaGammaLL::endJob() +void +GammaGammaLL::fetchVertices( const edm::Event& iEvent ) { - std::cout << "==> Number of candidates in the dataset : " << nCandidates << std::endl; + // Get the vertex collection from the event + edm::Handle > recoVertexColl; + iEvent.getByToken( recoVertexToken_, recoVertexColl ); + + for ( unsigned int i = 0; i < recoVertexColl->size() && evt_.nPrimVertexCand < ggll::AnalysisEvent::MAX_VTX; ++i ) { + const edm::Ptr vertex = recoVertexColl->ptrAt( i); + + evt_.PrimVertexCand_x[evt_.nPrimVertexCand] = vertex->x(); + evt_.PrimVertexCand_y[evt_.nPrimVertexCand] = vertex->y(); + evt_.PrimVertexCand_z[evt_.nPrimVertexCand] = vertex->z(); + evt_.PrimVertexCand_tracks[evt_.nPrimVertexCand] = vertex->nTracks(); + evt_.PrimVertexCand_chi2[evt_.nPrimVertexCand] = vertex->chi2(); + evt_.PrimVertexCand_ndof[evt_.nPrimVertexCand] = vertex->ndof(); + evt_.nPrimVertexCand++; + } } -// ------------ method called when starting to processes a run ------------ -void -GammaGammaLL::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) +void +GammaGammaLL::newVertexInfoRetrieval( const edm::Event& iEvent ) { - bool changed; - std::string triggerName_; - - changed = true; - if (hltConfig_.init(iRun, iSetup, hltMenuLabel_, changed)) { - if (changed) { - // check if trigger name in (new) config - triggerName_ = "HLT_DoubleMu0"; - if (triggerName_!="@") { // "@" means: analyze all triggers in config - const unsigned int n = hltConfig_.size(); - const unsigned int triggerIndex = hltConfig_.triggerIndex(triggerName_); - if (triggerIndex>=n) { - std::cout << "GammaGammaMuMu::analyze:" - << " TriggerName " << triggerName_ - << " not available in (new) config!" - << std::endl; - //std::cout << "Available TriggerNames are: " << std::endl; - //hltConfig_.dump("Triggers"); + iEvent.getByToken( recoTrackToken_, trackColl_ ); + + foundPairInEvent_ = false; + switch ( leptonsType_ ) { + case ggll::ElectronMuon: { + for ( unsigned int i = 0; i < evt_.nMuonCand; ++i ) { + for ( unsigned int j = 0; j < evt_.nEleCand; ++j ) { + if ( evt_.MuonCand_charge[i]*evt_.EleCand_charge[j] > 0 ) continue; + if ( newTracksInfoRetrieval( i, j ) ) foundPairInEvent_ = true; + } + } + } break; + case ggll::DiElectron: { + for ( unsigned int i = 0; i < evt_.nEleCand; ++i ) { + for ( unsigned int j = i+1; j < evt_.nEleCand; ++j ) { + if ( evt_.EleCand_charge[i]*evt_.EleCand_charge[j] > 0 ) continue; + if ( newTracksInfoRetrieval( i, j ) ) foundPairInEvent_ = true; + } + } + } break; + case ggll::DiMuon: { + for ( unsigned int i = 0; i < evt_.nMuonCand; ++i ) { + for ( unsigned int j = i+1; j < evt_.nMuonCand; ++j ) { + if ( evt_.MuonCand_charge[i]*evt_.MuonCand_charge[j] > 0 ) continue; + if ( newTracksInfoRetrieval( i, j ) ) foundPairInEvent_ = true; } } - //hltConfig_.dump("Streams"); - //hltConfig_.dump("Datasets"); - //hltConfig_.dump("PrescaleTable"); - //hltConfig_.dump("ProcessPSet"); + } break; + default: + throw cms::Exception( "GammaGammaLL" ) << "invalid leptons type to be retrieved: " << leptonsType_; + } + fetchVertices( iEvent ); +} + +bool +GammaGammaLL::newTracksInfoRetrieval( int l1id, int l2id ) +{ + double l1cand_pt, l2cand_pt; + std::vector translepttrks; + + switch ( leptonsType_ ) { + case ggll::ElectronMuon: { + translepttrks.push_back(muonTransientTracks_[l1id] ); + translepttrks.push_back(eleTransientTracks_[l2id] ); + l1cand_pt = evt_.MuonCand_innerTrackPt[l1id]; + l2cand_pt = evt_.EleCand_innerTrackPt[l2id]; + } break; + case ggll::DiElectron: { + translepttrks.push_back(eleTransientTracks_[l1id] ); + translepttrks.push_back(eleTransientTracks_[l2id] ); + l1cand_pt = evt_.EleCand_innerTrackPt[l1id]; + l2cand_pt = evt_.EleCand_innerTrackPt[l2id]; + } break; + case ggll::DiMuon: { + translepttrks.push_back(muonTransientTracks_[l1id] ); + translepttrks.push_back(muonTransientTracks_[l2id] ); + l1cand_pt = evt_.MuonCand_innerTrackPt[l1id]; + l2cand_pt = evt_.MuonCand_innerTrackPt[l2id]; + } break; + default: throw cms::Exception( "GammaGammaLL" ) << "Invalid leptons type: " << leptonsType_; + } + + if ( translepttrks.size() < 2 ) return false; // just in case... + + const bool use_smoothing = true; + KalmanVertexFitter fitter( use_smoothing ); + TransientVertex dileptonVertex; + try { + dileptonVertex = fitter.vertex(translepttrks); + } catch (...) { return false; } + + if ( !dileptonVertex.isValid() ) return false; // only keep the pairs with valid vertex + + evt_.KalmanVertexCand_x[evt_.nPair] = dileptonVertex.position().x(); + evt_.KalmanVertexCand_y[evt_.nPair] = dileptonVertex.position().y(); + evt_.KalmanVertexCand_z[evt_.nPair] = dileptonVertex.position().z(); + + // Count nearby tracks + int closesttrkid = -1, closesthighpuritytrkid = -1; + double closesttrkdxyz = 999., closesthighpuritytrkdxyz = 999.; + + for ( unsigned int i = 0; i < trackColl_->size() && evt_.nExtraTracks < ggll::AnalysisEvent::MAX_ET; ++i ) { + const edm::Ptr track = trackColl_->ptrAt( i); + + if ( track->pt() == l1cand_pt || track->pt() == l2cand_pt) continue; + + const double vtxdst = sqrt( std::pow( ( track->vertex().x()-evt_.KalmanVertexCand_x[evt_.nPair] ), 2 ) + + std::pow( ( track->vertex().y()-evt_.KalmanVertexCand_y[evt_.nPair] ), 2 ) + + std::pow( ( track->vertex().z()-evt_.KalmanVertexCand_z[evt_.nPair] ), 2 ) ); + if ( vtxdst < 0.05 ) evt_.Pair_extratracks0p5mm[evt_.nPair]++; + if ( vtxdst < 0.1 ) evt_.Pair_extratracks1mm[evt_.nPair]++; + if ( vtxdst < 0.2 ) evt_.Pair_extratracks2mm[evt_.nPair]++; + if ( vtxdst < 0.3 ) evt_.Pair_extratracks3mm[evt_.nPair]++; + if ( vtxdst < 0.4 ) evt_.Pair_extratracks4mm[evt_.nPair]++; + if ( vtxdst < 0.5 ) evt_.Pair_extratracks5mm[evt_.nPair]++; + if ( vtxdst < 1.0 ) evt_.Pair_extratracks1cm[evt_.nPair]++; + if ( vtxdst < 2.0 ) evt_.Pair_extratracks2cm[evt_.nPair]++; + if ( vtxdst < 3.0 ) evt_.Pair_extratracks3cm[evt_.nPair]++; + if ( vtxdst < 4.0 ) evt_.Pair_extratracks4cm[evt_.nPair]++; + if ( vtxdst < 5.0 ) evt_.Pair_extratracks5cm[evt_.nPair]++; + if ( vtxdst < 10. ) evt_.Pair_extratracks10cm[evt_.nPair]++; + if ( vtxdst < closesttrkdxyz ) { + closesttrkid = i; + closesttrkdxyz = vtxdst; + } + if ( track->quality( reco::TrackBase::highPurity ) == 1 && vtxdst < closesthighpuritytrkdxyz ) { + closesthighpuritytrkid = i; + closesthighpuritytrkdxyz = vtxdst; + } + + // Save track properties if within 5mm + if ( (saveExtraTracks_ == true) && (vtxdst < 0.5) ) { + evt_.ExtraTrack_pair[evt_.nExtraTracks] = evt_.nPair; + evt_.ExtraTrack_purity[evt_.nExtraTracks] = track->quality( reco::TrackBase::highPurity ); + evt_.ExtraTrack_nhits[evt_.nExtraTracks] = track->numberOfValidHits(); + + evt_.ExtraTrack_px[evt_.nExtraTracks] = track->px(); + evt_.ExtraTrack_py[evt_.nExtraTracks] = track->py(); + evt_.ExtraTrack_pz[evt_.nExtraTracks] = track->pz(); + evt_.ExtraTrack_charge[evt_.nExtraTracks] = track->charge(); + evt_.ExtraTrack_chi2[evt_.nExtraTracks] = track->chi2(); + evt_.ExtraTrack_ndof[evt_.nExtraTracks] = track->ndof(); + evt_.ExtraTrack_vtxdxyz[evt_.nExtraTracks] = vtxdst; + evt_.ExtraTrack_vtxT[evt_.nExtraTracks] = std::hypot( track->vertex().x()-evt_.KalmanVertexCand_x[evt_.nPair], + track->vertex().y()-evt_.KalmanVertexCand_y[evt_.nPair] ); + evt_.ExtraTrack_vtxZ[evt_.nExtraTracks] = fabs( track->vertex().z()-evt_.KalmanVertexCand_z[evt_.nPair] ); + evt_.ExtraTrack_x[evt_.nExtraTracks] = track->vertex().x(); + evt_.ExtraTrack_y[evt_.nExtraTracks] = track->vertex().y(); + evt_.ExtraTrack_z[evt_.nExtraTracks] = track->vertex().z(); + + evt_.nExtraTracks++; } } - else { - std::cout << "GammaGammaMuMu::beginRun:" - << " config extraction failure with process name " - << hltMenuLabel_ - << std::endl; + evt_.ClosestExtraTrack_vtxdxyz[evt_.nPair] = closesttrkdxyz; + evt_.ClosestExtraTrack_id[evt_.nPair] = closesttrkid; + evt_.ClosestHighPurityExtraTrack_vtxdxyz[evt_.nPair] = closesthighpuritytrkdxyz; + evt_.ClosestHighPurityExtraTrack_id[evt_.nPair] = closesthighpuritytrkid; + + TLorentzVector l1, l2; + switch (leptonsType_ ) { + case ggll::ElectronMuon: { + l1.SetPtEtaPhiE( evt_.MuonCand_pt[l1id], evt_.MuonCand_eta[l1id], evt_.MuonCand_phi[l1id], evt_.MuonCand_e[l1id] ); + l2.SetPtEtaPhiE( evt_.EleCand_et[l2id], evt_.EleCand_eta[l2id], evt_.EleCand_phi[l2id], evt_.EleCand_e[l2id] ); + } break; + case ggll::DiElectron: { + l1.SetPtEtaPhiE( evt_.EleCand_et[l1id], evt_.EleCand_eta[l1id], evt_.EleCand_phi[l1id], evt_.EleCand_e[l1id] ); + l2.SetPtEtaPhiE( evt_.EleCand_et[l2id], evt_.EleCand_eta[l2id], evt_.EleCand_phi[l2id], evt_.EleCand_e[l2id] ); + } break; + case ggll::DiMuon: { + l1.SetPtEtaPhiE( evt_.MuonCand_pt[l1id], evt_.MuonCand_eta[l1id], evt_.MuonCand_phi[l1id], evt_.MuonCand_e[l1id] ); + l2.SetPtEtaPhiE( evt_.MuonCand_pt[l2id], evt_.MuonCand_eta[l2id], evt_.MuonCand_phi[l2id], evt_.MuonCand_e[l2id] ); + } break; + default: throw cms::Exception( "GammaGammaLL" ) << "Invalid leptons type: " << leptonsType_; } - hltPrescale_.init(iRun, iSetup, hltMenuLabel_, changed); + + const TLorentzVector pair = l1+l2; + + if ( minMpair_ > 0. && pair.M() < minMpair_ ) + return false; + if ( maxMpair_ > 0. && pair.M() > maxMpair_ ) + return false; + + evt_.Pair_pt[evt_.nPair] = pair.Pt(); + evt_.Pair_mass[evt_.nPair] = pair.M(); + evt_.Pair_phi[evt_.nPair] = pair.Phi(); + evt_.Pair_eta[evt_.nPair] = pair.Eta(); + evt_.Pair_lepton1[evt_.nPair] = l1id; + evt_.Pair_lepton2[evt_.nPair] = l2id; + + double dphi = fabs( l1.Phi()-l2.Phi() ); + // dphi lies in [-pi, pi] + while ( dphi < -M_PI ) dphi += 2.*M_PI; + while ( dphi > M_PI ) dphi -= 2.*M_PI; + evt_.Pair_dphi[evt_.nPair] = dphi; + + evt_.Pair_dpt[evt_.nPair] = fabs( l1.Pt()-l2.Pt() ); + evt_.Pair_3Dangle[evt_.nPair] = l1.Angle( l2.Vect() )/M_PI; + + evt_.nPair++; + nCandidates_++; + + + return true; } -// ------------ method called when ending the processing of a run ------------ -void -GammaGammaLL::endRun(edm::Run const&, edm::EventSetup const&) +// ------------ method called once each job just before starting event loop ------------ +void +GammaGammaLL::beginJob() { + // Filling the ntuple + evt_.attach( tree_, leptonsType_, runOnMC_, saveExtraTracks_ ); + *evt_.HLT_Name = triggersList_; } -// ------------ method called when starting to processes a luminosity block ------------ -void -GammaGammaLL::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +// ------------ method called once each job just after ending the event loop ------------ +void +GammaGammaLL::endJob() { + std::cout << "==> Number of candidates in the dataset : " << nCandidates_ << std::endl; } -// ------------ method called when ending the processing of a luminosity block ------------ -void -GammaGammaLL::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +// ------------ method called when starting to processes a run ------------ +void +GammaGammaLL::beginRun( const edm::Run& iRun, const edm::EventSetup& iSetup ) { + bool changed = true; + if ( !hltPrescale_.init( iRun, iSetup, triggerResults_.process(), changed ) ) + edm::LogError( "GammaGammaLL" ) << "prescales extraction failure with process name " << triggerResults_.process(); + + // Initialise HLTConfigProvider + hltConfig_ = hltPrescale_.hltConfigProvider(); + if ( hltConfig_.size() == 0 ) + edm::LogError( "GammaGammaLL" ) << "HLT config size error"; } // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void -GammaGammaLL::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +GammaGammaLL::fillDescriptions( edm::ConfigurationDescriptions& descriptions ) { //The following says we do not know what parameters are allowed so do no validation // Please change this to state exactly what you do use, even if it is no parameters edm::ParameterSetDescription desc; desc.setUnknown(); - descriptions.addDefault(desc); + descriptions.addDefault( desc ); } //define this as a plug-in -DEFINE_FWK_MODULE(GammaGammaLL); +DEFINE_FWK_MODULE( GammaGammaLL ); + diff --git a/GammaGammaLeptonLepton/plugins/GammaGammaLL.h b/GammaGammaLeptonLepton/plugins/GammaGammaLL.h deleted file mode 100644 index 4498fa2..0000000 --- a/GammaGammaLeptonLepton/plugins/GammaGammaLL.h +++ /dev/null @@ -1,391 +0,0 @@ -#ifndef DiffractiveForwardAnalysis_GammaGammaLL_h -#define DiffractiveForwardAnalysis_GammaGammaLL_h - -// system include files -#include -#include -#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 "FWCore/ParameterSet/interface/Registry.h" - -// HLT information -#include "DataFormats/Common/interface/TriggerResults.h" -#include "FWCore/Common/interface/TriggerNames.h" -#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h" -#include "HLTrigger/HLTcore/interface/HLTPrescaleProvider.h" - -// Generator level collection -#include "DataFormats/Candidate/interface/Candidate.h" -#include "DataFormats/Candidate/interface/CandidateFwd.h" -#include "DataFormats/HepMCCandidate/interface/GenParticle.h" -#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" -#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" - -// Pileup -#include "DataFormats/Luminosity/interface/LumiSummary.h" -#include "DataFormats/Luminosity/interface/LumiDetails.h" -#include "PhysicsTools/Utilities/interface/LumiReWeighting.h" -#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" - -// Muons collection -#include "DataFormats/PatCandidates/interface/Muon.h" -#include "DataFormats/MuonReco/interface/Muon.h" -//#include "DataFormats/MuonReco/interface/MuonFwd.h" -//#include "DataFormats/MuonReco/interface/MuonSelectors.h" - -// Electrons collection -#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" -#include "DataFormats/PatCandidates/interface/Electron.h" -//#include "EgammaAnalysis/ElectronTools/interface/EGammaCutBasedEleId.h" -//#include "EGamma/EGammaAnalysisTools/interface/EGammaCutBasedEleId.h" -#include "DataFormats/EgammaCandidates/interface/Conversion.h" -#include "RecoEgamma/EgammaTools/interface/ConversionTools.h" - -// Particle flow collection -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" - -// Vertices collection -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/Common/interface/RefToBase.h" -#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" - -// Jets/MET collection -#include "DataFormats/PatCandidates/interface/Jet.h" -#include "DataFormats/PatCandidates/interface/MET.h" -#include "DataFormats/METReco/interface/PFMETCollection.h" -#include "DataFormats/JetReco/interface/CaloJetCollection.h" - -// HPS acceptance -#include "DiffractiveForwardAnalysis/GammaGammaLeptonLepton/interface/AcceptanceTableHelper.h" -#include "DiffractiveForwardAnalysis/GammaGammaLeptonLepton/interface/PrimaryVertexSelector.h" -#include "DiffractiveForwardAnalysis/GammaGammaLeptonLepton/interface/HLTMatcher.h" - -#include -#include -#include -#include -#include - -#define MAX_HLT 10 // Maximum number of HLT to check -#define MAX_LL 50 // Maximum number of leptons per event -#define MAX_MUONS 25 // Maximum number of muons per event -#define MAX_ELE 25 // Maximum number of electrons per event -#define MAX_PHO 50 // Maximum number of photons per event -#define MAX_PAIRS 25 // Maximum number of leptons pairs per event -#define MAX_VTX 1000 // Maximum number of primary vertices per event -#define MAX_ET 10000// Maximum number of extra tracks per event -#define MAX_GENMU 25 // Maximum number of generator level muons per event -#define MAX_GENELE 25 // Maximum number of generator level electrons per event -#define MAX_GENPHO 10 // Maximum number of generator level photons per event -#define MAX_GENPRO 8 // Maximum number of generator level protons per event -#define MAX_JETS 30 // Maximum number of jets per event - -#define MASS_MU 0.1057 -#define MASS_E 0.000511 -#define MASS_P 0.938272029 -#define pi 3.14159265359 - -typedef std::vector< edm::Handle< edm::ValueMap > > IsoDepositVals; - -// -// class declaration -// - -class GammaGammaLL : public edm::EDAnalyzer { - public: - explicit GammaGammaLL(const edm::ParameterSet&); - ~GammaGammaLL(); - - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - - private: - virtual void beginJob() ; - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - - virtual void beginRun(edm::Run const&, edm::EventSetup const&); - virtual void endRun(edm::Run const&, edm::EventSetup const&); - virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); - virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); - - virtual void LookAtTriggers(const edm::Event&, const edm::EventSetup&); - - // ----------member data --------------------------- - unsigned int i; - int lep1, lep2; - double vtxdst; - double closesttrkdxyz, closesthighpuritytrkdxyz; - int closesttrkid, closesthighpuritytrkid; - int parttype; - double leadingphotpx, leadingphotpy, leadingphotpz, leadingphotp; - double photdeta, photdphi, photdr; - double endphotdeta, endphotdphi, endphotdr; - double pairgmass; - bool istight; - - std::ofstream *logfile; - - // Input tags - std::string hltMenuLabel_, outputFile_; - std::vector triggersList_, leptonsType_; - edm::EDGetTokenT beamSpotToken_; - edm::EDGetTokenT recoVertexToken_; - edm::EDGetTokenT genToken_; - edm::EDGetTokenT< edm::View > muonToken_; - edm::EDGetTokenT< edm::View > eleToken_; - edm::EDGetTokenT< edm::ValueMap > eleLooseIdMapToken_; - edm::EDGetTokenT< edm::ValueMap > eleMediumIdMapToken_; - edm::EDGetTokenT< edm::ValueMap > eleTightIdMapToken_; - edm::EDGetTokenT conversionsToken_; - // rhoIsoLabel_; - edm::EDGetTokenT< std::vector > pileupToken_; - edm::EDGetTokenT< edm::View > pflowToken_; - edm::EDGetTokenT< edm::View > jetToken_; - edm::EDGetTokenT< edm::View > metToken_; - std::vector isoValLabel_; - bool runOnMC_, printCandidates_; - double minPtMC_, minEtaMC_; - double sqrts_; - unsigned int maxExTrkVtx_; - - // Beam spot - edm::Handle beamspot_h; - - // Generator level information - edm::Handle genPartColl; - reco::GenParticleCollection::const_iterator genPart; - std::string fullAcceptancePath; - edm::FileInPath *myDataFile; - // HPS acceptance tables - TFile* f; - AcceptanceTableHelper helper420beam1, helper220beam1, helper420a220beam1; - AcceptanceTableHelper helper420beam2, helper220beam2, helper420a220beam2; - - // Trigger information - HLTMatcher* _hlts; - HLTConfigProvider hltConfig_; - HLTPrescaleProvider hltPrescale_; - edm::Handle hltResults_; - - // Pileup information - edm::LumiReWeighting *LumiWeights; - edm::Handle< std::vector > pileupInfo; - std::vector::const_iterator PVI; - int sum_nvtx, beamXing; - int npv, npvtrue, npvm1true, npvp1true, npv0true, npv0; - std::string mcPileupFile_, mcPileupPath_, dataPileupFile_, dataPileupPath_; - - bool _fetchMuons, _fetchElectrons; - - // Two-leptons matching - bool foundPairInEvent, foundPairOnVertex; - bool foundGenCandPairInEvent; - double leptonsDist, minDist; - TLorentzVector* _leptonptmp; - TLorentzVector l1, l2; - std::map muonsMomenta, electronsMomenta; - - // Isolation - double rhoIso; - double iso_ch, iso_em, iso_nh; // Electron isolation quantities - int vtxind; // Primary vertex index (used in loop over vertices) - int etind; // Extra tracks on vertex index (used in loop over tracks) - - // Vertices - edm::Handle recoVertexColl; - reco::VertexCollection::const_iterator vertex; - TString* _leptonType; - - // PAT muons - edm::Handle > muonColl; - edm::View::const_iterator muon; - // AOD muons - /*edm::Handle muonColl; - reco::MuonCollection::const_iterator muon;*/ - - // PAT electrons - edm::Handle > eleColl; - edm::View::const_iterator electron; - // RECO electrons - edm::Handle eleCollRECO; - edm::Handle conversions_h; - edm::Handle rhoIso_h; - - TLorentzVector pair; - double dphi; - - // Particle Flow - edm::Handle pflowColl; - reco::PFCandidateCollection::const_iterator pflow; - - // Jets/MET - edm::Handle > jetColl; - edm::View::const_iterator jet; - edm::Handle MET; - reco::PFMETCollection::const_iterator met; - double HEJet_e, HEJet_eta, HEJet_phi; - double totalJetEnergy; - - ////// Tree contents ////// - - // Run/event quantities - int BX, Run, LumiSection, EventNum; - //double AvgInstDelLumi, BunchInstLumi[3]; - - // HLT quantities - int nHLT; - int HLT_Accept[MAX_HLT], HLT_Prescl[MAX_HLT]; - /*int nHLTLeptonCand[MAX_HLT]; - double HLTLeptonCand_pt[2][MAX_HLT]; - double HLTLeptonCand_eta[2][MAX_HLT]; - double HLTLeptonCand_phi[2][MAX_HLT]; - int HLTLeptonCand_charge[2][MAX_HLT]; - int HLT_LeadingLepton[MAX_HLT], HLT_TrailingLepton[MAX_HLT]; - int HLT_LeadingLepton_Prescl[MAX_HLT], HLT_TrailingLepton_Prescl[MAX_HLT];*/ - - // Generator level quantities - int nGenMuonCand, nGenMuonCandOutOfAccept; - double GenMuonCand_px[MAX_GENMU], GenMuonCand_py[MAX_GENMU], GenMuonCand_pz[MAX_GENMU]; - double GenMuonCand_p[MAX_GENMU], GenMuonCand_pt[MAX_GENMU]; - double GenMuonCand_eta[MAX_GENMU], GenMuonCand_phi[MAX_GENMU]; - int nGenEleCand, nGenEleCandOutOfAccept; - double GenEleCand_px[MAX_GENELE], GenEleCand_py[MAX_GENELE], GenEleCand_pz[MAX_GENELE]; - double GenEleCand_p[MAX_GENELE], GenEleCand_pt[MAX_GENELE]; - double GenEleCand_eta[MAX_GENELE], GenEleCand_phi[MAX_GENELE]; - double GenPair_p, GenPair_pt, GenPair_mass; - double GenPair_phi, GenPair_eta; - double GenPair_dphi, GenPair_dpt, GenPair_3Dangle; - int nGenPhotCand, nGenPhotCandOutOfAccept; - double GenPhotCand_p[MAX_GENPHO], GenPhotCand_e[MAX_GENPHO]; - double GenPhotCand_pt[MAX_GENPHO], GenPhotCand_eta[MAX_GENPHO], GenPhotCand_phi[MAX_GENPHO]; - int nGenProtCand; - double GenProtCand_p[MAX_GENPRO], GenProtCand_px[MAX_GENPRO], GenProtCand_py[MAX_GENPRO], GenProtCand_pz[MAX_GENPRO]; - double GenProtCand_pt[MAX_GENPRO], GenProtCand_eta[MAX_GENPRO], GenProtCand_phi[MAX_GENPRO]; - int GenProtCand_status[MAX_GENPRO]; - - // HPS quantities - double xi, t; - double HPS_acc420b1, HPS_acc220b1, HPS_acc420and220b1, HPS_acc420or220b1; // beam 1 (clockwise) - double HPS_acc420b2, HPS_acc220b2, HPS_acc420and220b2, HPS_acc420or220b2; // beam 2 (anti-clockwise) - - int nLeptonCand, nLeptonsInPrimVertex, nCandidates, nCandidatesInEvent; - - // Pileup reweighting quantities - double nTruePUafterPUWeight; - double nTruePUafterPUWeightBXM1, nTruePUafterPUWeightBXP1, nTruePUafterPUWeightBX0; - double PUWeightTrue; - int nTruePUforPUWeight; - int nTruePUforPUWeightBXM1, nTruePUforPUWeightBXP1, nTruePUforPUWeightBX0; - double Weight; - - // Muon quantities - int nMuonCand; - double MuonCand_px[MAX_LL], MuonCand_py[MAX_LL], MuonCand_pz[MAX_LL]; - double MuonCand_p[MAX_LL], MuonCand_pt[MAX_LL]; - double MuonCand_eta[MAX_LL], MuonCand_phi[MAX_LL]; - double MuonCand_vtxx[MAX_LL], MuonCand_vtxy[MAX_LL], MuonCand_vtxz[MAX_LL]; - int MuonCand_charge[MAX_LL]; - double MuonCand_dxy[MAX_LL], MuonCand_dz[MAX_LL]; - int MuonCand_nstatseg[MAX_LL], MuonCand_npxlhits[MAX_LL], MuonCand_ntrklayers[MAX_LL]; - double MuonCand_[MAX_LL]; - int MuonCandTrack_nmuchits[MAX_LL]; - double MuonCandTrack_chisq[MAX_LL]; - int MuonCand_isglobal[MAX_LL], MuonCand_istracker[MAX_LL], MuonCand_isstandalone[MAX_LL], MuonCand_ispfmuon[MAX_LL]; - int MuonCand_istight[MAX_LL]; - - // Electron quantities - int nEleCand; - double EleCand_px[MAX_LL], EleCand_py[MAX_LL], EleCand_pz[MAX_LL]; - double EleCand_p[MAX_LL], EleCand_e[MAX_LL], EleCand_et[MAX_LL]; - double EleCand_eta[MAX_LL], EleCand_phi[MAX_LL]; - double EleCand_vtxx[MAX_LL], EleCand_vtxy[MAX_LL], EleCand_vtxz[MAX_LL]; - int EleCand_charge[MAX_LL]; - double EleCandTrack_p[MAX_LL], EleCandTrack_pt[MAX_LL]; - double EleCandTrack_eta[MAX_LL], EleCandTrack_phi[MAX_LL]; - double EleCandTrack_vtxz[MAX_LL]; - double EleCand_deltaPhi[MAX_LL], EleCand_deltaEta[MAX_LL]; - double EleCand_HoverE[MAX_LL]; - double EleCand_trackiso[MAX_LL], EleCand_ecaliso[MAX_LL], EleCand_hcaliso[MAX_LL]; - double EleCand_sigmaIetaIeta[MAX_LL]; - double EleCand_convDist[MAX_LL], EleCand_convDcot[MAX_LL]; - int EleCand_ecalDriven[MAX_LL]; - int EleCand_tightID[MAX_LL], EleCand_mediumID[MAX_LL], EleCand_looseID[MAX_LL]; - - // PF Photon quantities - int nPFPhotonCand; - double PFPhotonCand_px[MAX_PHO], PFPhotonCand_py[MAX_PHO], PFPhotonCand_pz[MAX_PHO]; - double PFPhotonCand_p[MAX_PHO], PFPhotonCand_pt[MAX_PHO]; - double PFPhotonCand_eta[MAX_PHO], PFPhotonCand_phi[MAX_PHO]; - double PFPhotonCand_drtrue[MAX_PHO], PFPhotonCand_detatrue[MAX_PHO], PFPhotonCand_dphitrue[MAX_PHO]; - - // Pair quantities - int Pair_candidates[MAX_PAIRS][2]; - double Pair_mindist[MAX_PAIRS]; - double Pair_p[MAX_PAIRS], Pair_pt[MAX_PAIRS], Pair_dpt[MAX_PAIRS]; - double Pair_mass[MAX_PAIRS], Pair_dphi[MAX_PAIRS]; - double Pair_eta[MAX_PAIRS], Pair_phi[MAX_PAIRS], Pair_3Dangle[MAX_PAIRS]; - double PairGamma_mass[MAX_PAIRS][MAX_PHO]; - // Extra tracks - int Pair_extratracks1mm[MAX_PAIRS], Pair_extratracks2mm[MAX_PAIRS]; - int Pair_extratracks3mm[MAX_PAIRS], Pair_extratracks4mm[MAX_PAIRS]; - int Pair_extratracks5mm[MAX_PAIRS], Pair_extratracks1cm[MAX_PAIRS]; - int Pair_extratracks2cm[MAX_PAIRS], Pair_extratracks3cm[MAX_PAIRS]; - int Pair_extratracks4cm[MAX_PAIRS], Pair_extratracks5cm[MAX_PAIRS]; - int Pair_extratracks10cm[MAX_PAIRS]; - - // Vertex quantities - int nPrimVertexCand; - int PrimVertexCand_id[MAX_VTX], PrimVertexCand_hasdil[MAX_VTX]; - double PrimVertexCand_x[MAX_VTX], PrimVertexCand_y[MAX_VTX], PrimVertexCand_z[MAX_VTX]; - int PrimVertexCand_tracks[MAX_VTX], PrimVertexCand_matchedtracks[MAX_VTX], PrimVertexCand_unmatchedtracks[MAX_VTX]; - double PrimVertexCand_chi2[MAX_VTX]; - int PrimVertexCand_ndof[MAX_VTX]; - int nFilteredPrimVertexCand; - - // Extra tracks on vertex quantities - int nExtraTracks; - int ExtraTrack_purity[MAX_ET], ExtraTrack_nhits[MAX_ET]; - int ExtraTrack_charge[MAX_ET], ExtraTrack_ndof[MAX_ET]; - int ExtraTrack_vtxId[MAX_ET]; - double ExtraTrack_p[MAX_ET], ExtraTrack_pt[MAX_ET]; - double ExtraTrack_px[MAX_ET], ExtraTrack_py[MAX_ET], ExtraTrack_pz[MAX_ET]; - double ExtraTrack_eta[MAX_ET], ExtraTrack_phi[MAX_ET]; - double ExtraTrack_chi2[MAX_ET]; - double ExtraTrack_vtxdxyz[MAX_ET]; - double ExtraTrack_vtxT[MAX_ET], ExtraTrack_vtxZ[MAX_ET]; - double ExtraTrack_x[MAX_ET], ExtraTrack_y[MAX_ET], ExtraTrack_z[MAX_ET]; - double ClosestExtraTrack_vtxdxyz[MAX_VTX], ClosestHighPurityExtraTrack_vtxdxyz[MAX_VTX]; - int ClosestExtraTrack_id[MAX_VTX], ClosestHighPurityExtraTrack_id[MAX_VTX]; - int nQualityExtraTrack; - - // Jets/MET quantities - int nJetCand; - double JetCand_px[MAX_JETS], JetCand_py[MAX_JETS], JetCand_pz[MAX_JETS]; - double JetCand_e[MAX_JETS], JetCand_eta[MAX_JETS], JetCand_phi[MAX_JETS]; - double HighestJet_e, HighestJet_eta, HighestJet_phi; - double SumJet_e; - double Etmiss, Etmiss_phi, Etmiss_x, Etmiss_y, Etmiss_z, Etmiss_significance; -}; - -// -// constants, enums and typedefs -// - -// -// static data member definitions -// -TFile* file_; -TTree* tree_; - -#endif diff --git a/GammaGammaLeptonLepton/plugins/SinglePhotonTreeProducer.cc b/GammaGammaLeptonLepton/plugins/SinglePhotonTreeProducer.cc new file mode 100644 index 0000000..6a4252d --- /dev/null +++ b/GammaGammaLeptonLepton/plugins/SinglePhotonTreeProducer.cc @@ -0,0 +1,312 @@ +// -*- C++ -*- +// +// Package: DiffractiveForwardAnalysis/SinglePhotonTreeProducer +// Class: SinglePhotonTreeProducer +// +/**\class SinglePhotonTreeProducer SinglePhotonTreeProducer.cc DiffractiveForwardAnalysis/SinglePhotonTreeProducer/plugins/SinglePhotonTreeProducer.cc + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Laurent Forthomme +// Created: Tue, 24 Jul 2018 12:24:16 GMT +// +// + +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "FWCore/Common/interface/TriggerNames.h" + +#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h" +#include "HLTrigger/HLTcore/interface/HLTPrescaleProvider.h" + +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "DataFormats/PatCandidates/interface/Photon.h" +#include "DataFormats/PatCandidates/interface/Jet.h" +#include "DataFormats/PatCandidates/interface/MET.h" + +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + +#include "DiffractiveForwardAnalysis/GammaGammaLeptonLepton/interface/SinglePhotonEvent.h" + +class SinglePhotonTreeProducer : public edm::one::EDAnalyzer +{ + public: + explicit SinglePhotonTreeProducer( const edm::ParameterSet& ); + ~SinglePhotonTreeProducer() {} + + static void fillDescriptions( edm::ConfigurationDescriptions& descriptions ); + + private: + virtual void beginRun( const edm::Run&, const edm::EventSetup& ); + + virtual void beginJob() override; + virtual void analyze( const edm::Event&, const edm::EventSetup& ) override; + virtual void endJob() override {} + + TTree* tree_; + gggx::SinglePhotonEvent evt_; + + std::string hltMenuLabel_; + std::vector triggersList_; + bool runOnMC_; + unsigned int minPhotonMult_, minFwdTrks_; + + edm::EDGetTokenT triggerResultsToken_; + edm::EDGetTokenT > photonToken_; + edm::EDGetTokenT > phoWP80IdMapToken_, phoWP90IdMapToken_; + edm::EDGetTokenT > ppsTracksToken_; + edm::EDGetTokenT > verticesToken_; + edm::EDGetTokenT > jetsToken_; + edm::EDGetTokenT > metsToken_; + + HLTConfigProvider hltConfig_; + HLTPrescaleProvider hltPrescale_; +}; + +SinglePhotonTreeProducer::SinglePhotonTreeProducer( const edm::ParameterSet& iConfig ) : + hltMenuLabel_ ( iConfig.getParameter( "hltMenuTag" ) ), + triggersList_ ( iConfig.getParameter >( "triggersList" ) ), + runOnMC_ ( iConfig.getParameter( "runOnMC" ) ), + minPhotonMult_ ( iConfig.getParameter( "minPhotonMult" ) ), + minFwdTrks_ ( iConfig.getParameter( "minFwdTrks" ) ), + triggerResultsToken_( consumes ( iConfig.getParameter( "triggerResults" ) ) ), + photonToken_ ( consumes > ( iConfig.getParameter( "photonsTag" ) ) ), + phoWP80IdMapToken_ ( consumes > ( iConfig.getParameter( "phoWP80IdMap" ) ) ), + phoWP90IdMapToken_ ( consumes > ( iConfig.getParameter( "phoWP90IdMap" ) ) ), + ppsTracksToken_ ( consumes >( iConfig.getParameter( "ppsTracksTag" ) ) ), + verticesToken_ ( consumes > ( iConfig.getParameter( "verticesTag" ) ) ), + jetsToken_ ( consumes > ( iConfig.getParameter( "jetsTag" ) ) ), + metsToken_ ( consumes > ( iConfig.getParameter( "metsTag" ) ) ), + hltPrescale_ ( iConfig, consumesCollector(), *this ) +{ + usesResource( "TFileService" ); + edm::Service fs; + tree_ = fs->make( "ntp1", "ntp1" ); +} + + +void +SinglePhotonTreeProducer::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup ) +{ + evt_.clear(); + + // Run and BX information + evt_.BX = iEvent.bunchCrossing(); + evt_.Run = iEvent.id().run(); + evt_.LumiSection = iEvent.luminosityBlock(); + evt_.EventNum = iEvent.id().event(); + + //--- trigger information + edm::Handle hltResults; + iEvent.getByToken( triggerResultsToken_, hltResults ); + const edm::TriggerNames& trigNames = iEvent.triggerNames( *hltResults ); + + evt_.HLT_Name.reserve( trigNames.size() ); + for ( const auto& sel : triggersList_ ) { + short trig_id = -1; + const std::string trig_name = ( sel.size() > 1 && sel[sel.size()-1] == '*' ) + ? sel.substr( 0, sel.size()-1 ) // remove trailing '*' + : sel; + for ( unsigned int i = 0; i < trigNames.size(); ++i ) + if ( trigNames.triggerNames().at( i ).find( trig_name ) != std::string::npos ) { + trig_id = i; + break; + } + if ( trig_id < 0 ) + continue; + evt_.HLT_Name[evt_.nHLT] = trigNames.triggerNames().at( trig_id ); + evt_.HLT_Accept[evt_.nHLT] = hltResults->accept( trig_id ); + evt_.HLT_Prescl[evt_.nHLT] = 0.; + // extract prescale value for this path + if ( !runOnMC_ ) { + int prescale_set = hltPrescale_.prescaleSet( iEvent, iSetup ); + evt_.HLT_Prescl[evt_.nHLT] = ( prescale_set < 0 ) + ? 0. + : hltConfig_.prescaleValue(prescale_set, trigNames.triggerNames().at( trig_id ) ); + } + evt_.nHLT++; + } + + //--- photons collection retrieval + edm::Handle > photonColl; + iEvent.getByToken( photonToken_, photonColl ); + + //--- photon identification + edm::Handle > wp80_id_decisions, wp90_id_decisions; + iEvent.getByToken( phoWP80IdMapToken_, wp80_id_decisions ); + iEvent.getByToken( phoWP90IdMapToken_, wp90_id_decisions ); + + for ( unsigned int i = 0; i < photonColl->size(); ++i ) { + const edm::Ptr photon = photonColl->ptrAt( i ); + + evt_.PhotonCand_pt[evt_.nPhotonCand] = photon->pt(); + evt_.PhotonCand_eta[evt_.nPhotonCand] = photon->eta(); + evt_.PhotonCand_phi[evt_.nPhotonCand] = photon->phi(); + evt_.PhotonCand_e[evt_.nPhotonCand] = photon->energy(); + evt_.PhotonCand_r9[evt_.nPhotonCand] = photon->r9(); + + evt_.PhotonCand_wp80id[evt_.nPhotonCand] = wp80_id_decisions->operator[]( photon ); + evt_.PhotonCand_wp90id[evt_.nPhotonCand] = wp90_id_decisions->operator[]( photon ); + + evt_.PhotonCand_electronveto[evt_.nPhotonCand] = photon->passElectronVeto(); + evt_.PhotonCand_pixelseed[evt_.nPhotonCand] = photon->hasPixelSeed(); + + evt_.PhotonCand_drtrue[evt_.nPhotonCand] = -999.; + evt_.PhotonCand_detatrue[evt_.nPhotonCand] = -999.; + evt_.PhotonCand_dphitrue[evt_.nPhotonCand] = -999.; + + if ( runOnMC_ ) { + double photdr = 999., photdeta = 999., photdphi = 999.; + double endphotdr = 999., endphotdeta = 999., endphotdphi = 999.; + for ( unsigned int j = 0; j < evt_.nGenPhotCand; ++j ) { // matching with the 'true' photon object from MC + photdeta = ( evt_.PhotonCand_eta[evt_.nPhotonCand]-evt_.GenPhotCand_eta[j] ); + photdphi = ( evt_.PhotonCand_phi[evt_.nPhotonCand]-evt_.GenPhotCand_phi[j] ); + photdr = sqrt( photdeta*photdeta + photdphi*photdphi ); + if ( photdr < endphotdr ) { + endphotdr = photdr; + endphotdeta = photdeta; + endphotdphi = photdphi; + } + } + evt_.PhotonCand_detatrue[evt_.nPhotonCand] = endphotdeta; + evt_.PhotonCand_dphitrue[evt_.nPhotonCand] = endphotdphi; + evt_.PhotonCand_drtrue[evt_.nPhotonCand] = endphotdr; + } + + evt_.nPhotonCand++; + } + //--- do not store if minimal number of photons is not reached + if ( evt_.nPhotonCand < minPhotonMult_ ) + return; + + //--- PPS local tracks + edm::Handle > ppsTracks; + iEvent.getByToken( ppsTracksToken_, ppsTracks ); + for ( const auto& trk : *ppsTracks ) { + if ( evt_.nFwdTrkCand >= gggx::SinglePhotonEvent::MAX_FWDTRKCAND-1 ) { + edm::LogWarning( "SinglePhotonTreeProducer" ) + << "maximum number of local tracks in RPs is reached! increase MAX_FWDTRKCAND=" + << gggx::SinglePhotonEvent::MAX_FWDTRKCAND; + break; + } + const CTPPSDetId detid( trk.getRPId() ); + evt_.FwdTrkCand_arm[evt_.nFwdTrkCand] = detid.arm(); + evt_.FwdTrkCand_station[evt_.nFwdTrkCand] = detid.station(); + evt_.FwdTrkCand_pot[evt_.nFwdTrkCand] = detid.rp(); + evt_.FwdTrkCand_x[evt_.nFwdTrkCand] = trk.getX()/1.e3; + evt_.FwdTrkCand_y[evt_.nFwdTrkCand] = trk.getY()/1.e3; + evt_.FwdTrkCand_xSigma[evt_.nFwdTrkCand] = trk.getXUnc()/1.e3; + evt_.FwdTrkCand_ySigma[evt_.nFwdTrkCand] = trk.getYUnc()/1.e3; + evt_.nFwdTrkCand++; + LogDebug( "SinglePhotonTreeProducer" ) + << "Proton track candidate with origin: ( " << trk.getX() << ", " << trk.getY() << " ) extracted!"; + } + //--- do not store if minimal number of PPS tracks is not reached + if ( evt_.nFwdTrkCand < minFwdTrks_ ) + return; + + //--- vertex collection + edm::Handle > verticesColl; + iEvent.getByToken( verticesToken_, verticesColl ); + + for ( unsigned int i = 0; i < verticesColl->size() && evt_.nPrimVertexCand < gggx::SinglePhotonEvent::MAX_VTX; ++i ) { + const edm::Ptr vertex = verticesColl->ptrAt( i ); + + evt_.PrimVertexCand_x[evt_.nPrimVertexCand] = vertex->x(); + evt_.PrimVertexCand_y[evt_.nPrimVertexCand] = vertex->y(); + evt_.PrimVertexCand_z[evt_.nPrimVertexCand] = vertex->z(); + evt_.PrimVertexCand_tracks[evt_.nPrimVertexCand] = vertex->nTracks(); + evt_.PrimVertexCand_chi2[evt_.nPrimVertexCand] = vertex->chi2(); + evt_.PrimVertexCand_ndof[evt_.nPrimVertexCand] = vertex->ndof(); + evt_.nPrimVertexCand++; + } + + //--- jets collection + edm::Handle > jetColl; + iEvent.getByToken( jetsToken_, jetColl ); + + double totalJetEnergy = 0., HEJet_pt = 0., HEJet_eta = 0., HEJet_phi = 0., HEJet_e = 0.; + + for ( unsigned int i = 0; i < jetColl->size() && evt_.nJetCand < gggx::SinglePhotonEvent::MAX_JETS; ++i ) { + const edm::Ptr jet = jetColl->ptrAt( i ); + + evt_.JetCand_e[evt_.nJetCand] = jet->energy(); + evt_.JetCand_pt[evt_.nJetCand] = jet->pt(); + evt_.JetCand_eta[evt_.nJetCand] = jet->eta(); + evt_.JetCand_phi[evt_.nJetCand] = jet->phi(); + totalJetEnergy += jet->energy(); + //--- find the highest energy jet + if ( evt_.JetCand_e[evt_.nJetCand] > HEJet_e ) { + HEJet_e = evt_.JetCand_e[evt_.nJetCand]; + HEJet_pt = evt_.JetCand_pt[evt_.nJetCand]; + HEJet_eta = evt_.JetCand_eta[evt_.nJetCand]; + HEJet_phi = evt_.JetCand_phi[evt_.nJetCand]; + } + evt_.nJetCand++; + } + evt_.HighestJet_pt = HEJet_pt; + evt_.HighestJet_eta = HEJet_eta; + evt_.HighestJet_phi = HEJet_phi; + evt_.HighestJet_e = HEJet_e; + evt_.SumJet_e = totalJetEnergy; + + //--- missing ET + edm::Handle > mets; + iEvent.getByToken( metsToken_, mets ); + const edm::View* metColl = mets.product(); + edm::View::const_iterator met = metColl->begin(); + + evt_.Etmiss = met->et(); + evt_.Etmiss_phi = met->phi(); + evt_.Etmiss_significance = met->significance(); + + + tree_->Fill(); +} + +void +SinglePhotonTreeProducer::beginRun( const edm::Run& iRun, const edm::EventSetup& iSetup ) +{ + //--- HLT part + bool changed = true; + if ( !hltPrescale_.init( iRun, iSetup, hltMenuLabel_, changed ) ) + throw cms::Exception( "GammaGammaLL" ) << " prescales extraction failure with process name " << hltMenuLabel_; + // Initialise HLTConfigProvider + hltConfig_ = hltPrescale_.hltConfigProvider(); + if ( !hltConfig_.init( iRun, iSetup, hltMenuLabel_, changed ) ) + throw cms::Exception( "GammaGammaLL" ) << " config extraction failure with process name " << hltMenuLabel_; + else if ( hltConfig_.size() == 0 ) + edm::LogError( "GammaGammaLL" ) << "HLT config size error"; +} + +void +SinglePhotonTreeProducer::beginJob() +{ + evt_.attach( tree_, runOnMC_ ); +} + +void +SinglePhotonTreeProducer::fillDescriptions( edm::ConfigurationDescriptions& descriptions ) +{ + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault( desc ); +} + +//define this as a plug-in +DEFINE_FWK_MODULE( SinglePhotonTreeProducer ); diff --git a/GammaGammaLeptonLepton/python/GammaGammaLL_cfi.py b/GammaGammaLeptonLepton/python/GammaGammaLL_cfi.py index c1df211..3470ff9 100644 --- a/GammaGammaLeptonLepton/python/GammaGammaLL_cfi.py +++ b/GammaGammaLeptonLepton/python/GammaGammaLL_cfi.py @@ -1,33 +1,63 @@ import FWCore.ParameterSet.Config as cms -ggll = cms.EDAnalyzer( - 'GammaGammaLL', - SqrtS = cms.double(8000.), - HLTMenuLabel = cms.string("HLT"), - LeptonsType = cms.InputTag('electron', 'muon'), - maxExtraTracks = cms.untracked.uint32(10000), - isoValInputTags = cms.VInputTag( - cms.InputTag('elPFIsoValueCharged03PFIdPFIso'), - cms.InputTag('elPFIsoValueGamma03PFIdPFIso'), - cms.InputTag('elPFIsoValueNeutral03PFIdPFIso') - ), - beamSpotInputTag = cms.InputTag('offlineBeamSpot'), - conversionsInputTag = cms.InputTag('allConversions'), - #eleLooseIdMap = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V2-standalone-loose"), - #eleMediumIdMap = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V2-standalone-medium"), - #eleTightIdMap = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V2-standalone-tight"), - eleLooseIdMap = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"), - eleMediumIdMap = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"), - eleTightIdMap = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"), - #eleLooseIdMap = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring15-25ns-Trig-V1-wp90"), - #eleMediumIdMap = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring15-25ns-Trig-V1-wp90"), - #eleTightIdMap = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring15-25ns-Trig-V1-wp80"), - rhoIsoInputTag = cms.InputTag('kt6PFJetsForIsolation', 'rho'), - JetCollectionLabel = cms.InputTag('selectedPatJetsPFlow'), - MetLabel = cms.InputTag('pfMet'), - RunOnMC = cms.untracked.bool(True), +ggll_aod = cms.EDAnalyzer('GammaGammaLL', + # General parameters + leptonsType = cms.InputTag('ElectronMuon'), + #maxExtraTracks = cms.untracked.uint32(10000), + sqrtS = cms.double(13.e3), # in GeV + fetchProtons = cms.bool(False), # retrieve the TOTEM/PPS info from the files (data only!) + printCandidates = cms.bool(False), + + # MC tweaks + runOnMC = cms.bool(True), MCAcceptPtCut = cms.untracked.double(0.), MCAcceptEtaCut = cms.untracked.double(-1.), - GenParticlesCollectionLabel = cms.InputTag('genParticles'), - PrintCandidates = cms.untracked.bool(False), + + # HLT selection + triggerEvent = cms.InputTag('patTriggerEvent'), + triggerResults = cms.InputTag('TriggerResults', '', 'HLT'), + + # Input collections + #muonTag = cms.InputTag("muons"), # RECO ; needs recompilation! + muonTag = cms.InputTag("patMuons"), # PAT + #electronTag = cms.InputTag("gsfElectrons"), # RECO ; needs recompilation! + electronTag = cms.InputTag("patElectrons"), # PAT + vertexTag = cms.InputTag('offlinePrimaryVertices'), + trackTag = cms.InputTag('generalTracks'), + jetTag = cms.InputTag('patJets'), + metTag = cms.InputTag('patMETs'), + photonTag = cms.InputTag('selectedPatPhotons'), + ppsLocalTrackTag = cms.InputTag('ctppsLocalTrackLiteProducer'), + ppsRecoProtonTag = cms.InputTag('ctppsProtonReconstructionOFDB'), + + genParticleTag = cms.InputTag('genParticles'), + + # Pileup reweighting + pileupInfo = cms.InputTag('addPileupInfo'), + mcpufile = cms.string('PUHistos_mc.root'), + mcpupath = cms.string('pileup'), + datapufile = cms.string('PUHistos_data.root'), + datapupath = cms.string('pileup'), + fixedGridRhoFastjetAllLabel = cms.InputTag('fixedGridRhoFastjetAll'), +) + +ggll = ggll_aod.clone() ## for backward-compatibility + +ggll_aod_pflow = ggll_aod.clone( + muonTag = cms.InputTag("selectedPatMuonsPFlow"), + electronTag = cms.InputTag("selectedPatElectronsPFlow"), + jetTag = cms.InputTag('selectedPatJetsPFlow'), + metTag = cms.InputTag('pfMet'), +) + +ggll_miniaod = ggll_aod.clone( + vertexTag = cms.InputTag('offlineSlimmedPrimaryVertices'), + muonTag = cms.InputTag("slimmedMuons"), # PAT + electronTag = cms.InputTag("slimmedElectrons"), # PAT + jetTag = cms.InputTag('slimmedJetsAK8'), + photonTag = cms.InputTag('slimmedPhotons'), + metTag = cms.InputTag('slimmedMETs'), # PAT + genParticleTag = cms.InputTag('prunedGenParticles'), + #pfTag = cms.InputTag('packedPFCandidates'), + pileupInfo = cms.InputTag('slimmedAddPileupInfo'), ) diff --git a/GammaGammaLeptonLepton/python/singlePhotonTreeProducer_cfi.py b/GammaGammaLeptonLepton/python/singlePhotonTreeProducer_cfi.py new file mode 100644 index 0000000..bf6ce99 --- /dev/null +++ b/GammaGammaLeptonLepton/python/singlePhotonTreeProducer_cfi.py @@ -0,0 +1,16 @@ +import FWCore.ParameterSet.Config as cms + +singlePhotonTreeProducer = cms.EDAnalyzer('SinglePhotonTreeProducer', + #--- general steering parameters + runOnMC = cms.bool(True), + minPhotonMult = cms.uint32(1), # minimum number of photons in the event + minFwdTrks = cms.uint32(1), # minimum number of tracks in PPS stations + #--- input collections + hltMenuTag = cms.string('HLT'), + triggersList = cms.vstring(), + photonsTag = cms.InputTag('slimmedPhotons'), + ppsTracksTag = cms.InputTag('ctppsLocalTrackLiteProducer'), + verticesTag = cms.InputTag('offlineSlimmedPrimaryVertices'), + jetsTag = cms.InputTag('slimmedJetsAK8'), + metsTag = cms.InputTag('slimmedMETs'), +) diff --git a/GammaGammaLeptonLepton/test/RunGammaGammaLeptonLepton_cfg.py b/GammaGammaLeptonLepton/test/RunGammaGammaLeptonLepton_cfg.py index 7c5d2a3..b6b7558 100644 --- a/GammaGammaLeptonLepton/test/RunGammaGammaLeptonLepton_cfg.py +++ b/GammaGammaLeptonLepton/test/RunGammaGammaLeptonLepton_cfg.py @@ -3,151 +3,188 @@ process = cms.Process("ggll") runOnMC = False +useAOD = True # AOD or MiniAOD? +#useAOD = False ######################### # General options # ######################### + process.load("FWCore.MessageService.MessageLogger_cfi") process.options = cms.untracked.PSet( #wantSummary = cms.untracked.bool(True), - SkipEvent = cms.untracked.vstring('ProductNotFound') + #SkipEvent = cms.untracked.vstring('ProductNotFound'), + allowUnscheduled = cms.untracked.bool(True), ) +#process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) -#process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) ) -#process.MessageLogger.cerr.FwkReport.reportEvery = 1000 +process.MessageLogger.cerr.FwkReport.reportEvery = 1000 ######################### # Input files # ######################### + process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( - #'/store/data/Run2012A/SingleMu/AOD/22Jan2013-v1/20000/002F5062-346F-E211-BF00-1CC1DE04DF20.root', - '/store/mc/Run2015D/DoubleEG/AOD/04Dec2015-v1/10000/04D11E1B-BB9E-E511-AC1A-047D7B881D62.root', +#'/store/data/Run2016G/DoubleEG/AOD/23Sep2016-v1/100000/0042DBD3-BA8E-E611-919E-002481ACDAA8.root', +#'/store/data/Run2017C/DoubleMuon/AOD/12Sep2017-v1/10000/029F251F-B1A2-E711-AAC3-001E67792890.root', +#'/store/data/Run2018B/DoubleMuon/MINIAOD/17Sep2018-v1/00000/8E1342C6-AA35-9049-B101-B5B595EAAEE2.root' +#'/store/data/Run2017C/DoubleMuon/AOD/17Nov2017-v1/30001/30DDB6DA-CBD8-E711-AF2A-A4BF0112BCB4.root' +#'file:/tmp/jjhollar/8816F63B-C0D5-E711-B32B-002590D9D9F0.root' + +#'/store/data/Run2017D/DoubleMuon/AOD/17Nov2017-v1/30000/6482D69E-48D6-E711-9AF7-008CFAF71FB4.root' +#'file:/tmp/jjhollar/6482D69E-48D6-E711-9AF7-008CFAF71FB4.root' +#'file:/tmp/jjhollar/F2C53386-ABFA-4A4F-B851-0065858DB53C.root' +'file:/tmp/jjhollar/14D52021-5DDE-E711-8A48-02163E01453B.root' + ), - firstEvent = cms.untracked.uint32(540) + #firstEvent = cms.untracked.uint32(0) ) ######################### # Triggers # ######################### + process.load("DiffractiveForwardAnalysis.GammaGammaLeptonLepton.HLTFilter_cfi") process.hltFilter.TriggerResultsTag = cms.InputTag("TriggerResults","","HLT") -process.hltFilter.HLTPaths = ['HLT_Mu10_Ele10_CaloIdL_*', 'HLT_Mu8_Ele17_*', 'HLT_Mu17_Ele8_*'] +process.hltFilter.HLTPaths = cms.vstring( + 'HLT_DoubleMu43NoFiltersNoVtx_*', + 'HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass3p8_*', + 'HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8_*' +# 'HLT_DoubleEle33_CaloIdL_MW_v*', +# 'HLT_Ele27_HighEta_Ele20_Mass55_v*', +# 'HLT_DoubleEle33_CaloIdL_GsfTrkIdVL_MW_v*', +) ######################### # Preskimming # ######################### process.load("Configuration.StandardSequences.GeometryDB_cff") ## FIXME need to ensure that this is the good one process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") -#process.GlobalTag.globaltag = cms.string('START52_V9::All') -#process.GlobalTag.globaltag = cms.string('FT_R_53_V6::All') from Configuration.AlCa.GlobalTag import GlobalTag process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data') process.load("Configuration.StandardSequences.MagneticField_cff") process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi") -process.scrapingVeto = cms.EDFilter("FilterOutScraping", - applyfilter = cms.untracked.bool(True), - debugOn = cms.untracked.bool(False), - numtrack = cms.untracked.uint32(10), - thresh = cms.untracked.double(0.2) -) - -process.primaryVertexFilter = cms.EDFilter("GoodVertexFilter", - vertexCollection = cms.InputTag('offlinePrimaryVertices'), - minimumNDOF = cms.uint32(4) , - maxAbsZ = cms.double(15), - maxd0 = cms.double(2) -) - -process.muonFilter = cms.EDFilter("CandViewCountFilter", - src = cms.InputTag("muons"), - minNumber = cms.uint32(1) -) ######################### # PAT-ification # ######################### ## Look at https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuidePATTools#Core_Tools for more information -# PAT Layer 0+1 -process.load("PhysicsTools.PatAlgos.patSequences_cff") -from Configuration.EventContent.EventContent_cff import * -from PhysicsTools.PatAlgos.patEventContent_cff import patEventContentNoCleaning, patExtraAodEventContent -from PhysicsTools.PatAlgos.tools.coreTools import * - -# -# rho value for isolation -# -#from RecoJets.JetProducers.kt4PFJets_cfi import * -#process.kt6PFJetsForIsolation = kt4PFJets.clone( rParam = 0.6, doRhoFastjet = True ) -#process.kt6PFJetsForIsolation.Rho_EtaMax = cms.double(2.5) -# -# Particle flow isolation -# -#from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFMuonIso -#process.eleIsoSequence = setupPFElectronIso(process, 'gsfElectrons') -#process.pfiso = cms.Sequence(process.pfParticleSelectionSequence + process.eleIsoSequence) process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string('PATuple.root'), outputCommands = cms.untracked.vstring( 'drop *', - 'keep *_offlinePrimaryVertices*_*_*', - 'keep *_*Muons*_*_*', - 'keep *_*Electrons*_*_*', - #'keep *_*Photons*_*_*', - 'keep *_*Jets*_*_*', + 'keep *_offline*PrimaryVertices*_*_*', + 'keep *_selectedPatMuons*_*_*', + 'keep *_*lectron*_*_*', + 'keep *_selectedPatElectrons*_*_*', + 'keep *_selectedPat*Photons*_*_*', + 'keep *_selectedPatJets*_*_*', 'keep *_*MET*_*_*', - 'keep recoPFCandidates_particleFlow_*_*', - #*patEventContentNoCleaning + 'keep *_*particleFlow*_*_*', ), ) +from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask +patAlgosToolsTask = getPatAlgosToolsTask(process) + +process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff") +patAlgosToolsTask.add(process.patCandidatesTask) + +process.load("PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff") +patAlgosToolsTask.add(process.selectedPatCandidatesTask) + +from PhysicsTools.PatAlgos.tools.coreTools import runOnData +if not runOnMC: + runOnData( process ) + +######################### +# Electron ID # +######################### -# Particle flow -#from PhysicsTools.PatAlgos.tools.pfTools import * -#postfix = "PFlow" -#jetAlgo="AK5" -##usePFBRECO(process,runPFBRECO=True, jetAlgo=jetAlgo, runOnMC=runOnMC, postfix=postfix) -#usePF2PAT(process,runPF2PAT=True, jetAlgo=jetAlgo, runOnMC=runOnMC, postfix=postfix) -#useGsfElectrons(process,postfix) -#removeCleaning(process) -#removeMCMatching(process, ['All']) - -useAOD = False +#from PhysicsTools.SelectorUtils.tools.vid_id_tools import switchOnVIDElectronIdProducer, setupVIDElectronSelection, setupAllVIDIdsInModule, DataFormat from PhysicsTools.SelectorUtils.tools.vid_id_tools import * -if useAOD==True: dataFormat = DataFormat.AOD -else: dataFormat = DataFormat.MiniAOD -switchOnVIDElectronIdProducer(process, dataFormat) -setupAllVIDIdsInModule(process, 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff', setupVIDElectronSelection) +switchOnVIDElectronIdProducer(process, DataFormat.AOD) +#setupAllVIDIdsInModule(process, 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff', setupVIDElectronSelection) +setupAllVIDIdsInModule(process, 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff', setupVIDElectronSelection) + +######################### +# Photon ID # +######################### + +switchOnVIDPhotonIdProducer(process, DataFormat.AOD) +setupAllVIDIdsInModule(process, 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff', setupVIDPhotonSelection) + +######################### +# Proton RECO # +######################### +process.load("RecoCTPPS.ProtonReconstruction.year_2017_OF.ctppsProtonReconstructionOF_cfi") +#process.load("RecoCTPPS.ProtonReconstruction.year_2018_OFDB.ctppsProtonReconstructionOFDB_cfi") +# conditions DB for 2018 + +#from CondCore.CondDB.CondDB_cfi import * +# +#CondDB.connect = 'frontier://FrontierProd/CMS_CONDITIONS' +# +#process.PoolDBESSource2 = cms.ESSource("PoolDBESSource", +# CondDB, +# DumpStat = cms.untracked.bool(False), +# toGet = cms.VPSet(cms.PSet( +# record = cms.string('LHCInfoRcd'), +# #tag = cms.string("LHCInfoTest_prompt_v3") +# tag = cms.string("LHCInfoEndFill_prompt_v1") +# )), +# ) ######################### # Analysis # ######################### + process.load("DiffractiveForwardAnalysis.GammaGammaLeptonLepton.GammaGammaLL_cfi") -process.ggll.TriggersList = process.hltFilter.HLTPaths -#process.ggll.LeptonsType = cms.vstring('Muon') -process.ggll.LeptonsType = cms.vstring('Electron', 'Muon') -#process.ggll.LeptonsType = cms.vstring('Electron') -process.ggll.RecoVertexLabel = cms.InputTag("offlinePrimaryVertices") -#process.ggll.GlobalMuonCollectionLabel = cms.untracked.InputTag("muons") # RECO -#process.ggll.GlobalMuonCollectionLabel = cms.untracked.InputTag("selectedPatMuonsPFlow"), # PAT (particle flow) -process.ggll.GlobalMuonCollectionLabel = cms.untracked.InputTag("selectedPatMuons") # PAT -#process.ggll.GlobalEleCollectionLabel = cms.untracked.InputTag("gsfElectrons") # RECO -#process.ggll.GlobalEleCollectionLabel = cms.untracked.InputTag("selectedPatElectronsPFlow") # PAT (particle flow) -process.ggll.GlobalEleCollectionLabel = cms.untracked.InputTag("selectedPatElectrons") # PAT -process.ggll.RunOnMC = cms.untracked.bool(runOnMC) -process.ggll.outfilename = cms.untracked.string('output.root') + +process.ggll_aod.triggersList = process.hltFilter.HLTPaths +process.ggll_aod.leptonsType = cms.string('Muon') +#process.ggll_aod.leptonsType = cms.string('ElectronMuon') +#process.ggll_aod.leptonsType = cms.string('Electron') +process.ggll_aod.runOnMC = cms.bool(runOnMC) +process.ggll_aod.fetchProtons = cms.bool(True) +process.ggll_aod.saveExtraTracks = cms.bool(False) +process.ggll_aod.year = cms.string('2017') + + +# E/gamma identification +process.ggll_aod.eleIdLabels = cms.PSet( + mediumLabel = cms.InputTag('mvaEleID-Spring16-GeneralPurpose-V1-wp90'), + tightLabel = cms.InputTag('mvaEleID-Spring16-GeneralPurpose-V1-wp80'), +) +process.ggll_aod.phoIdLabels = cms.PSet( + mediumLabel = cms.InputTag('mvaPhoID-Spring16-nonTrig-V1-wp90'), + tightLabel = cms.InputTag('mvaPhoID-Spring16-nonTrig-V1-wp80'), +) +#process.ggll_aod.eleMediumIdMap = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp90") +#process.ggll_aod.eleTightIdMap = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp80") +#process.ggll_aod.phoMediumIdMap = cms.InputTag("egmPhotonIDs:mvaPhoID-Spring16-nonTrig-V1-wp90") +#process.ggll_aod.phoTightIdMap = cms.InputTag("egmPhotonIDs:mvaPhoID-Spring16-nonTrig-V1-wp80") + +# prepare the output file +process.TFileService = cms.Service('TFileService', + fileName = cms.string('output.root'), + closeFileFast = cms.untracked.bool(True) +) process.p = cms.Path( - process.egmGsfElectronIDSequence+ - #process.scrapingVeto+ - #process.kt6PFJetsForIsolation+ - #process.pfiso+ - process.primaryVertexFilter+ - process.patDefaultSequence+ - #getattr(process,"patPF2PATSequence"+postfix)+ - process.ggll + process.hltFilter* + process.egmPhotonIDSequence* + process.egmGsfElectronIDSequence* + process.ctppsProtonReconstructionOFDB * + process.ggll_aod ) -#getattr(process,"pfNoElectron"+postfix).enable = True + +#process.outpath = cms.EndPath(process.out, patAlgosToolsTask) +process.outpath = cms.EndPath(patAlgosToolsTask) + +#print process.dumpPython() From e7a47154a30fb5cff15b19e81e3e59ede19fe420 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 26 Feb 2019 17:43:46 +0100 Subject: [PATCH 2/4] Changes for standard proton reco validation --- GammaGammaLeptonLepton/plugins/BuildFile.xml | 85 +++++++++------- GammaGammaLeptonLepton/src/HLTMatcher.cc | 42 ++++---- .../src/PrimaryVertexSelector.cc | 98 +++++++------------ 3 files changed, 106 insertions(+), 119 deletions(-) diff --git a/GammaGammaLeptonLepton/plugins/BuildFile.xml b/GammaGammaLeptonLepton/plugins/BuildFile.xml index ce02c9a..dada1f4 100644 --- a/GammaGammaLeptonLepton/plugins/BuildFile.xml +++ b/GammaGammaLeptonLepton/plugins/BuildFile.xml @@ -1,38 +1,47 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GammaGammaLeptonLepton/src/HLTMatcher.cc b/GammaGammaLeptonLepton/src/HLTMatcher.cc index 4231e2a..5f03e67 100644 --- a/GammaGammaLeptonLepton/src/HLTMatcher.cc +++ b/GammaGammaLeptonLepton/src/HLTMatcher.cc @@ -18,30 +18,30 @@ // #include "DiffractiveForwardAnalysis/GammaGammaLeptonLepton/interface/HLTMatcher.h" -// -// constructors and destructor -// -HLTMatcher::HLTMatcher(std::vector _HLTlist) + +namespace ggll { - for (unsigned int i=0; i<_HLTlist.size(); i++) { - HLTnames.push_back(_HLTlist[i].substr(0, _HLTlist[i].find_first_of("*"))); - } + HLTMatcher::HLTMatcher(const std::vector& list) + { + for (unsigned int i=0; i " << HLTnames[i] << std::endl; - } + for (unsigned int i=0; i " << HLTnames[i] << std::endl; + } #endif -} - -HLTMatcher::~HLTMatcher() -{ -} + } -int -HLTMatcher::TriggerNum(std::string _trigName) -{ - for (unsigned int i=0; i trigger " << name << " matched with " << HLTnames[i] << std::endl; + return i; + } + } + return -1; } - return -1; } diff --git a/GammaGammaLeptonLepton/src/PrimaryVertexSelector.cc b/GammaGammaLeptonLepton/src/PrimaryVertexSelector.cc index 44b3893..e1a9564 100644 --- a/GammaGammaLeptonLepton/src/PrimaryVertexSelector.cc +++ b/GammaGammaLeptonLepton/src/PrimaryVertexSelector.cc @@ -22,78 +22,56 @@ // // constructors and destructor // -PrimaryVertexSelector::PrimaryVertexSelector(std::vector& _leptonsType, std::map& _muonsMomenta, std::map& _electronsMomenta) : - nTracks(0), - nMatchedTracks(0), - nUnmatchedTracks(0), - nMatchedMuons(0), - nMatchedElectrons(0), - FetchMuons(false), - FetchElectrons(false) +PrimaryVertexSelector::PrimaryVertexSelector(const std::map& mu, const std::map& ele) : + muonMomenta_(mu), electronMomenta_(ele) { - //LeptonsType = _leptonsType; - for (i=0; i<_leptonsType.size(); i++) { - if (_leptonsType[i]=="Muon") { - FetchMuons = true; - } - else if (_leptonsType[i]=="Electron") { - FetchElectrons = true; - } - } - MuonMomenta = _muonsMomenta; - ElectronMomenta = _electronsMomenta; -} - -PrimaryVertexSelector::~PrimaryVertexSelector() { -} - -void -PrimaryVertexSelector::SetPosition(double _x, double _y, double _z) -{ - Position.SetXYZ(_x, _y, _z); -#ifdef DEBUG - std::cout << "[PrimaryVertexSelector] SetPosition :: Vertex located at (" << Position.x() << ", " << Position.y() << ", " << Position.z() << ")" << std::endl; -#endif } /** * \brief Matches a track arising from the vertex with a lepton track from the * internal collection */ -int -PrimaryVertexSelector::AddTrack(const reco::TrackRef& _track, TString& _leptonType) +void +PrimaryVertexSelector::feedTracks(const reco::Vertex::trackRef_iterator& begin, const reco::Vertex::trackRef_iterator& end) { - nTracks++; // total number of tracks matched with the vertex - std::map::iterator lep; - for (lep=MuonMomenta.begin(); lep!=MuonMomenta.end(); lep++) { - if (fabs(_track->p()-lep->second.P())>.01) continue; - if (fabs(_track->pt()-lep->second.Pt())>.01) continue; - if (fabs(_track->eta()-lep->second.Eta())>.01) continue; - if (fabs(_track->phi()-lep->second.Phi())>.01) continue; - _leptonType = "muon"; - MatchedMuons.push_back(lep->first); - nMatchedMuons++; - nMatchedTracks++; - return lep->first; + matchedElectrons_.clear(); + matchedMuons_.clear(); + + const float dr_max = 0.1; + + for (reco::Vertex::trackRef_iterator trk_it=begin; trk_it!=end; trk_it++) { + const reco::TrackRef trk = trk_it->castTo(); + + const TVector3 trk_vec(trk->px(), trk->py(), trk->pz()); + + // look at electron matching + for (LeptonsMap::const_iterator mu=muonMomenta_.begin(); mu!=muonMomenta_.end(); mu++) { + if (trk_vec.DeltaR(mu->second.Vect())>dr_max) continue; + matchedMuons_.push_back(std::pair(mu->first, trk)); + } + + // then look at muon matching + for (LeptonsMap::const_iterator ele=electronMomenta_.begin(); ele!=electronMomenta_.end(); ele++) { + if (trk_vec.DeltaR(ele->second.Vect())>dr_max) continue; + matchedElectrons_.push_back(std::pair(ele->first, trk)); + } } - for (lep=ElectronMomenta.begin(); lep!=ElectronMomenta.end(); lep++) { - if (fabs(_track->p()-lep->second.P())>.01) continue; - if (fabs(_track->pt()-lep->second.Pt())>.01) continue; - if (fabs(_track->eta()-lep->second.Eta())>.01) continue; - if (fabs(_track->phi()-lep->second.Phi())>.01) continue; - _leptonType = "electron"; - MatchedElectrons.push_back(lep->first); - nMatchedElectrons++; - nMatchedTracks++; - return lep->first; +} + +int +PrimaryVertexSelector::matchedElectron(const reco::TrackRef& trk) const +{ + for (MatchedLeptonsMap::const_iterator it=matchedElectrons_.begin(); it!=matchedElectrons_.end(); it++) { + if (it->second==trk); } - nUnmatchedTracks++; return -1; } -double -PrimaryVertexSelector::dZ(TVector3 _vmu, int _muind) +int +PrimaryVertexSelector::matchedMuon(const reco::TrackRef& trk) const { - TLorentzVector m(MuonMomenta[_muind]); - return (_vmu.Z()-Position.Z())-((_vmu.X()-Position.X())*m.Px()+(_vmu.Y()-Position.Y())*m.Py())/m.Pt()*m.Pz()/m.Pt(); + for (MatchedLeptonsMap::const_iterator it=matchedMuons_.begin(); it!=matchedMuons_.end(); it++) { + if (it->second==trk); + } + return -1; } From c3c30679856ce74606d622ba286ccb6cd34cbf4c Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 15 Apr 2019 10:59:56 +0200 Subject: [PATCH 3/4] add macros for dimuon resolution+scale studies --- .../macros/Dimuons2017Macro.C | 444 ++++++++++++++ .../macros/Dimuons2017Macro.h | 424 +++++++++++++ .../macros/MoreDimuons2017AllWithMultMC.root | Bin 0 -> 21914 bytes ...llWithMultSingleTrack_BCDEF_single_RC.root | Bin 0 -> 30847 bytes .../macros/SimpleResolutionFit.C | 181 ++++++ .../macros/SimpleResolutionFit.C~ | 179 ++++++ GammaGammaLeptonLepton/macros/StupidFit.C~ | 573 ++++++++++++++++++ 7 files changed, 1801 insertions(+) create mode 100644 GammaGammaLeptonLepton/macros/Dimuons2017Macro.C create mode 100644 GammaGammaLeptonLepton/macros/Dimuons2017Macro.h create mode 100644 GammaGammaLeptonLepton/macros/MoreDimuons2017AllWithMultMC.root create mode 100644 GammaGammaLeptonLepton/macros/MoreDimuons2017AllWithMultSingleTrack_BCDEF_single_RC.root create mode 100644 GammaGammaLeptonLepton/macros/SimpleResolutionFit.C create mode 100644 GammaGammaLeptonLepton/macros/SimpleResolutionFit.C~ create mode 100644 GammaGammaLeptonLepton/macros/StupidFit.C~ diff --git a/GammaGammaLeptonLepton/macros/Dimuons2017Macro.C b/GammaGammaLeptonLepton/macros/Dimuons2017Macro.C new file mode 100644 index 0000000..b885c90 --- /dev/null +++ b/GammaGammaLeptonLepton/macros/Dimuons2017Macro.C @@ -0,0 +1,444 @@ +#define Dimuons2017Macro_cxx +#include "Dimuons2017Macro.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "TH1.h" +#include "TF1.h" +#include "TFile.h" +#include "TH1F.h" +#include "TMath.h" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "RoccoR.cc" + + +#include +#include +#include + +#include "./align/alignment_classes.h" +#include "./align/fill_info.h" +#include "./align/fill_info.cc" + +using namespace std; +int getXangle(int run,int lumi, const char* filename); + + +void Dimuons2017Macro::Loop() +{ +int preTS2=1; + + + if (fChain == 0) return; + + TH1F *hacop = new TH1F("hacop","hacop",1000,0,0.01); + TH2F *hcorr45 = new TH2F("hcorr45","hcorr45",500,0,0.25,500,0,0.25); + TH2F *hcorr56 = new TH2F("hcorr56","hcorr56",500,0,0.25,500,0,0.25); + + TH1F *hres45 = new TH1F("hres45","hres45",300,-5,1); + TH1F *hres56 = new TH1F("hres56","hres56",300,-5,1); + TH1F *hressum = new TH1F("hressum","hressum",300,-5,1); + + TH1F *hbin145 = new TH1F("hbin145","hbin145",300,-5,1); + TH1F *hbin156 = new TH1F("hbin156","hbin156",300,-5,1); + TH1F *hbin1sum = new TH1F("hbin1sum","hbin1sum",300,-5,1); + TH1F *hbin245 = new TH1F("hbin245","hbin245",300,-5,1); + TH1F *hbin256 = new TH1F("hbin256","hbin256",300,-5,1); + TH1F *hbin2sum = new TH1F("hbin2sum","hbin2sum",300,-5,1); + TH1F *hbin345 = new TH1F("hbin345","hbin345",300,-5,1); + TH1F *hbin356 = new TH1F("hbin356","hbin356",300,-5,1); + TH1F *hbin3sum = new TH1F("hbin3sum","hbin3sum",300,-5,1); + + TH1F *hres45mult = new TH1F("hres45mult","hres45mult",300,-5,1); + TH1F *hres56mult = new TH1F("hres56mult","hres56mult",300,-5,1); + TH1F *hressummult = new TH1F("hressummult","hressummult",300,-5,1); + +RoccoR rc("RoccoR2017.txt"); + + +///////////////////////////////////////// + +// b2 + TFile *f_in_B2_120 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b2_120_murad.root"); + TFile *f_in_B2_130 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b2_130_murad.root"); + TFile *f_in_B2_140 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b2_140_murad.root"); + + TGraph *m_s_x_to_xi_120_l = (TGraph *) f_in_B2_120->Get("XRPH_B6L5_B2"); + TGraph *m_s_x_to_xi_130_l = (TGraph *) f_in_B2_130->Get("XRPH_B6L5_B2"); + TGraph *m_s_x_to_xi_140_l = (TGraph *) f_in_B2_140->Get("XRPH_B6L5_B2"); + + +// b1 + TFile *f_in_B1_120 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b1_120_murad.root"); + TFile *f_in_B1_130 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b1_130_murad.root"); + TFile *f_in_B1_140 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b1_140_murad.root"); + + TGraph *m_s_x_to_xi_120_r = (TGraph *) f_in_B1_120->Get("XRPH_B6R5_B1"); + TGraph *m_s_x_to_xi_130_r = (TGraph *) f_in_B1_130->Get("XRPH_B6R5_B1"); + TGraph *m_s_x_to_xi_140_r = (TGraph *) f_in_B1_140->Get("XRPH_B6R5_B1"); + +///////////////////////////////////////// + +double angle=0; + + +TGraph *graph[2]; +graph[0] = new TGraph(); +graph[1] = new TGraph(); + + + AlignmentResults *alignments = NULL; +AlignmentResultsCollection alignmentCollection; +if(preTS2==1) alignmentCollection.Load("./align/collect_alignments_2018_10_26.4.out"); +if(preTS2==0) alignmentCollection.Load("./align/collect_alignments_2018_10_25.5.out"); // post-TS2 +InitFillInfoCollection(); + + + // 0.02-0.05, 0.05-0.075, and 0.075-0.25 + + Int_t nentries = fChain->GetEntries(); + + Long64_t nbytes = 0, nb = 0; + for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; + // if (Cut(ientry) < 0) continue; + + if(jentry % 10000 == 0) + std::cout << "Entry " << jentry << "/" << nentries << std::endl; + + +////////////////////////////////////// +double dataSFa=0; +double dataSFb=0; +double corrMass=0; +dataSFa = rc.kScaleDT(MuonCand_charge[0], MuonCand_pt[0],MuonCand_eta[0],MuonCand_phi[0], 0, 0); +dataSFb = rc.kScaleDT(MuonCand_charge[1], MuonCand_pt[1],MuonCand_eta[1],MuonCand_phi[1], 0, 0); +double pt0cor=MuonCand_pt[0]*dataSFa; +double pt1cor=MuonCand_pt[1]*dataSFb; +TLorentzVector l1; +TLorentzVector l2; + +TLorentzVector mutmp1; +TLorentzVector mutmp2; +mutmp1.SetPtEtaPhiE(MuonCand_pt[0], MuonCand_eta[0], MuonCand_phi[0], MuonCand_e[0]); +mutmp2.SetPtEtaPhiE(MuonCand_pt[1], MuonCand_eta[1], MuonCand_phi[1], MuonCand_e[1]); + +TLorentzVector pair; +double MASS_MU=0.1057; + + l1.SetXYZM(mutmp1.Px()*dataSFa, + + mutmp1.Py()*dataSFa, + + mutmp1.Pz()*dataSFa, + + MASS_MU); + + l2.SetXYZM(mutmp2.Px()*dataSFb, + + mutmp2.Py()*dataSFb, + + mutmp2.Pz()*dataSFb, + + MASS_MU); +pair = l1+l2; +corrMass = pair.M(); + + + + + +///////////////////////////////////////// + if(/*Pair_mass[0]*/corrMass<110.) + continue; + if(/*MuonCand_pt[0]<50 || MuonCand_pt[1]<50*/pt0cor<50. || pt1cor<50.) + continue; + if(MuonCand_istight[0]!=1 || MuonCand_istight[1]!=1) + continue; + if(MuonCand_charge[0] == MuonCand_charge[1]) + continue; + if(1-fabs(Pair_dphi[0])/3.14159 > 0.009) + continue; + if(Pair_extratracks0p5mm[0] > 0) + continue; + +///////////////////// + + + +FillInfo fillInfo; +unsigned int ret = fillInfoCollection.FindByRun(Run, fillInfo); +const auto alignment_it = alignmentCollection.find(fillInfo.alignmentTag); +// alignments = &alignment_it->second; + // aligned=1; + + + +///////////////////////////////////////////////// +double shx_l=0; +double shx_r=0; + unsigned int rpDecId = 23; + shx_l = alignment_it->second.Apply(rpDecId,1,0); + rpDecId = 123; + shx_r = alignment_it->second.Apply(rpDecId,1,0); +double shx_l_s=0; +double shx_r_s=0; + rpDecId = 3; + shx_l_s = alignment_it->second.Apply(rpDecId,1,0); + rpDecId = 103; + shx_r_s = alignment_it->second.Apply(rpDecId,1,0); + + + +double shy_l=0; +double shy_r=0; +// unsigned int + rpDecId = 23; + shy_l = alignment_it->second.Apply(rpDecId,0,1); + rpDecId = 123; + shy_r = alignment_it->second.Apply(rpDecId,0,1); +double shy_l_s=0; +double shy_r_s=0; + rpDecId = 3; + shy_l_s = alignment_it->second.Apply(rpDecId,0,1); + rpDecId = 103; + shy_r_s = alignment_it->second.Apply(rpDecId,0,1); + + + + +/////////////////////// + + + hacop->Fill(1-fabs(Pair_dphi[0])/3.14159); + + Float_t mumuxisol1 = (1.0/13000.0)*((pt0cor*TMath::Exp(MuonCand_eta[0]) + pt1cor*TMath::Exp(MuonCand_eta[1]))); + Float_t mumuxisol2 = (1.0/13000.0)*((pt0cor*TMath::Exp(-1*MuonCand_eta[0]) + pt1cor*TMath::Exp(-1*MuonCand_eta[1]))); + + + Float_t protxi45 = 0.0; + Float_t protxi56 = 0.0; + Float_t mumuxi45 = 0.0; + Float_t mumuxi56 = 0.0; double prot_x_p=0; + Int_t ntrk45 = 0; + Int_t ntrk56 = 0; + +double prot_x_l=0; +double prot_x_r=0; + + for(Int_t p = 0; p < nLocalProtCand; p++) + {//if(ProtCand_ismultirp[p])continue; + + + + + +if(LocalProtCand_rpid[p] == 23) + { prot_x_l=LocalProtCand_x[p]+shx_l/1000.; + ntrk45++; + } + if(LocalProtCand_rpid[p] == 123) + { prot_x_r=LocalProtCand_x[p]+shx_r/1000.; + ntrk56++; + } + + + +/* + if(ProtCand_arm[p] == 0 && ProtCand_ismultirp[p] == 1) + { + protxi45 = ProtCand_xi[p]; + hres45mult->Fill(1 - (protxi45/mumuxisol1)); + hressummult->Fill(1 - (protxi45/mumuxisol1)); + } + + if(ProtCand_arm[p] == 1 && ProtCand_ismultirp[p] == 1) + { + protxi56 = ProtCand_xi[p]; + hres56mult->Fill(1 - (protxi56/mumuxisol2)); + hressummult->Fill(1 - (protxi56/mumuxisol2)); + } +*/ + } + + +///////////////////////////////////////////////////////// + +if(preTS2==1){ +if(ntrk45==1 || ntrk56==1){angle=getXangle(Run, LumiSection , "./inp/xangle_tillTS2_stableonly_cleanup.csv");} +} + + +if(preTS2==0){ +if(ntrk45==1 || ntrk56==1){angle=getXangle(Run, LumiSection , "./inp/xangle_afterTS2_cleanup.csv");} +} + + + if(ntrk45 ==1) + { prot_x_p=prot_x_l; + + protxi45 = fabs(m_s_x_to_xi_120_l->Eval( prot_x_p) + ( ((120.-angle)/(120.-140.))*(m_s_x_to_xi_140_l->Eval( prot_x_p )-m_s_x_to_xi_120_l->Eval( prot_x_p ) )) ); //ProtCand_xi[p]; + //protxi45 = ProtCand_xi[p]; + hcorr45->Fill(protxi45,mumuxisol1); + hres45->Fill(1 - (protxi45/mumuxisol1)); + hressum->Fill(1 - (protxi45/mumuxisol1)); + graph[0]->SetPoint(graph[0]->GetN(), protxi45 , mumuxisol1); + if(mumuxisol1 >= 0.02 && mumuxisol1 < 0.04) + hbin145->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.04 && mumuxisol1 < 0.06) + hbin245->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.07) + hbin345->Fill(1 - (protxi45/mumuxisol1)); + + ntrk45++; + } + if(ntrk56 ==1) + { prot_x_p=prot_x_r; + + + protxi56 = fabs(m_s_x_to_xi_120_r->Eval( prot_x_p) + ( ((120.-angle)/(120.-140.))*(m_s_x_to_xi_140_r->Eval( prot_x_p )-m_s_x_to_xi_120_r->Eval( prot_x_p ) )) ); //ProtCand_xi[p]; + + hcorr56->Fill(protxi56,mumuxisol2); + hres56->Fill(1 - (protxi56/mumuxisol2)); + hressum->Fill(1 - (protxi56/mumuxisol2)); + + + graph[1]->SetPoint(graph[1]->GetN(), protxi56 , mumuxisol2); + + if(mumuxisol2 >= 0.02 && mumuxisol2 < 0.04) + hbin156->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.04 && mumuxisol2 < 0.07) + hbin256->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.07) + hbin356->Fill(1 - (protxi56/mumuxisol2)); + + ntrk56++; + } + + }//loop + + TFile *fx = new TFile("MoreDimuons2017AllWithMultSingleTrack_BCD_single_RC.root","RECREATE"); +graph[0]->SetName("S45_xiRP_xiMUMU"); +// graph[i]->Draw("AP"); + graph[0]->Write(); +graph[1]->SetName("S56_xiRP_xiMUMU"); +// graph[i]->Draw("AP"); + graph[1]->Write(); + + + hacop->Write(); + hcorr45->Write(); + hres45->Write(); + hcorr56->Write(); + hres56->Write(); + hressum->Write(); + hres45mult->Write(); + hres56mult->Write(); + hressummult->Write(); + + hbin145->Write(); + hbin245->Write(); + hbin345->Write(); + + hbin156->Write(); + hbin256->Write(); + hbin356->Write(); + + fx->Write(); +} + + +int run() + { + Dimuons2017Macro m; + m.Loop(); + + return 0; + } + + + + + + +int getXangle(int run, int lumi, const char* filename) + { + TString drun; + TString dfill; + TString dlumi; + TString temp; + +int Xangle=-1; + + TString runs;runs.Form("%d", run); + TString lumis;lumis.Form("%d", lumi); + + + ifstream F; + F.open((const char*)filename); + + //F.clear(); + //F.seekg(0, ios::beg); + int counter=0; + if(F){ + while (!F.eof()) + { + + + F>>drun; + F>>dfill; + F>>dlumi; + F>>temp; + F>>Xangle; +//if(runfill==runlumi && ) + +if( runs == drun && lumis==dlumi ) + { + // cout << "Read: "<< run<<" " << lumi<<" -----> "< +#include +#include + +// Header file for the classes stored in the TTree if any. +#include "vector" + +class Dimuons2017Macro { +public : + TTree *fChain; //!pointer to the analyzed TTree or TChain + Int_t fCurrent; //!current Tree number in a TChain + +// Fixed size dimensions of array or collections stored in the TTree if any. + + // Declaration of leaf types + UInt_t Run; + UInt_t LumiSection; + UInt_t BX; + UInt_t EventNum; + UInt_t nHLT; + Int_t HLT_Accept[3]; //[nHLT] + Int_t HLT_Prescl[3]; //[nHLT] + vector *HLT_Name; + UInt_t nMuonCand; + Double_t MuonCand_pt[10]; //[nMuonCand] + Double_t MuonCand_eta[10]; //[nMuonCand] + Double_t MuonCand_phi[10]; //[nMuonCand] + Double_t MuonCand_e[10]; //[nMuonCand] + Int_t MuonCand_charge[10]; //[nMuonCand] + Double_t MuonCand_vtxx[10]; //[nMuonCand] + Double_t MuonCand_vtxy[10]; //[nMuonCand] + Double_t MuonCand_vtxz[10]; //[nMuonCand] + Double_t MuonCand_dxy[10]; //[nMuonCand] + Int_t MuonCand_nstatseg[10]; //[nMuonCand] + Int_t MuonCand_ntrklayers[10]; //[nMuonCand] + Int_t MuonCand_npxlhits[10]; //[nMuonCand] + Int_t MuonCand_isglobal[10]; //[nMuonCand] + Int_t MuonCand_istracker[10]; //[nMuonCand] + Int_t MuonCand_isstandalone[10]; //[nMuonCand] + Int_t MuonCand_ispfmuon[10]; //[nMuonCand] + Int_t MuonCand_istight[10]; //[nMuonCand] + Int_t MuonCandTrack_nmuchits[10]; //[nMuonCand] + Double_t MuonCandTrack_chisq[10]; //[nMuonCand] + Double_t MuonCand_innerTrackPt[10]; //[nMuonCand] + Double_t MuonCand_innerTrackEta[10]; //[nMuonCand] + Double_t MuonCand_innerTrackPhi[10]; //[nMuonCand] + Double_t MuonCand_innerTrackVtxz[10]; //[nMuonCand] + UInt_t nPrimVertexCand; + Double_t PrimVertexCand_x[97]; //[nPrimVertexCand] + Double_t PrimVertexCand_y[97]; //[nPrimVertexCand] + Double_t PrimVertexCand_z[97]; //[nPrimVertexCand] + Double_t PrimVertexCand_chi2[97]; //[nPrimVertexCand] + UInt_t PrimVertexCand_ndof[97]; //[nPrimVertexCand] + UInt_t PrimVertexCand_tracks[97]; //[nPrimVertexCand] + UInt_t nPair; + Int_t Pair_lepton1[10]; //[nPair] + Int_t Pair_lepton2[10]; //[nPair] + Double_t Pair_mass[10]; //[nPair] + Double_t Pair_pt[10]; //[nPair] + Double_t Pair_eta[10]; //[nPair] + Double_t Pair_phi[10]; //[nPair] + Double_t Pair_dpt[10]; //[nPair] + Double_t Pair_dphi[10]; //[nPair] + Double_t Pair_3Dangle[10]; //[nPair] + UInt_t Pair_extratracks0p5mm[10]; //[nPair] + UInt_t Pair_extratracks1mm[10]; //[nPair] + UInt_t Pair_extratracks2mm[10]; //[nPair] + UInt_t Pair_extratracks3mm[10]; //[nPair] + UInt_t Pair_extratracks4mm[10]; //[nPair] + UInt_t Pair_extratracks5mm[10]; //[nPair] + UInt_t Pair_extratracks1cm[10]; //[nPair] + UInt_t Pair_extratracks2cm[10]; //[nPair] + UInt_t Pair_extratracks3cm[10]; //[nPair] + UInt_t Pair_extratracks4cm[10]; //[nPair] + UInt_t Pair_extratracks5cm[10]; //[nPair] + UInt_t Pair_extratracks10cm[10]; //[nPair] + Double_t KalmanVertexCand_x[10]; //[nPair] + Double_t KalmanVertexCand_y[10]; //[nPair] + Double_t KalmanVertexCand_z[10]; //[nPair] + UInt_t nLocalProtCand; + Double_t LocalProtCand_x[100]; //[nLocalProtCand] + Double_t LocalProtCand_y[100]; //[nLocalProtCand] + Double_t LocalProtCand_t[100]; //[nLocalProtCand] + Double_t LocalProtCand_xSigma[100]; //[nLocalProtCand] + Double_t LocalProtCand_ySigma[100]; //[nLocalProtCand] + Double_t LocalProtCand_tSigma[100]; //[nLocalProtCand] + Int_t LocalProtCand_arm[100]; //[nLocalProtCand] + Int_t LocalProtCand_station[100]; //[nLocalProtCand] + Int_t LocalProtCand_pot[100]; //[nLocalProtCand] + Int_t LocalProtCand_rpid[100]; //[nLocalProtCand] + UInt_t nRecoProtCand; + Double_t ProtCand_xi[50]; //[nRecoProtCand] + Double_t ProtCand_t[50]; //[nRecoProtCand] + Double_t ProtCand_ThX[50]; //[nRecoProtCand] + Double_t ProtCand_ThY[50]; //[nRecoProtCand] + Int_t ProtCand_rpid[50]; //[nRecoProtCand] + Int_t ProtCand_arm[50]; //[nRecoProtCand] + Int_t ProtCand_ismultirp[50]; //[nRecoProtCand] + UInt_t nExtraTracks; + Int_t ExtraTrack_pair[2000]; //[nExtraTracks] + Int_t ExtraTrack_purity[2000]; //[nExtraTracks] + UInt_t ExtraTrack_nhits[2000]; //[nExtraTracks] + Int_t ExtraTrack_charge[2000]; //[nExtraTracks] + UInt_t ExtraTrack_ndof[2000]; //[nExtraTracks] + Double_t ExtraTrack_px[2000]; //[nExtraTracks] + Double_t ExtraTrack_py[2000]; //[nExtraTracks] + + // List of branches + TBranch *b_Run; //! + TBranch *b_LumiSection; //! + TBranch *b_BX; //! + TBranch *b_EventNum; //! + TBranch *b_nHLT; //! + TBranch *b_HLT_Accept; //! + TBranch *b_HLT_Prescl; //! + TBranch *b_HLT_Name; //! + TBranch *b_nMuonCand; //! + TBranch *b_MuonCand_pt; //! + TBranch *b_MuonCand_eta; //! + TBranch *b_MuonCand_phi; //! + TBranch *b_MuonCand_e; //! + TBranch *b_MuonCand_charge; //! + TBranch *b_MuonCand_vtxx; //! + TBranch *b_MuonCand_vtxy; //! + TBranch *b_MuonCand_vtxz; //! + TBranch *b_MuonCand_dxy; //! + TBranch *b_MuonCand_nstatseg; //! + TBranch *b_MuonCand_ntrklayers; //! + TBranch *b_MuonCand_npxlhits; //! + TBranch *b_MuonCand_isglobal; //! + TBranch *b_MuonCand_istracker; //! + TBranch *b_MuonCand_isstandalone; //! + TBranch *b_MuonCand_ispfmuon; //! + TBranch *b_MuonCand_istight; //! + TBranch *b_MuonCandTrack_nmuchits; //! + TBranch *b_MuonCandTrack_chisq; //! + TBranch *b_MuonCand_innerTrackPt; //! + TBranch *b_MuonCand_innerTrackEta; //! + TBranch *b_MuonCand_innerTrackPhi; //! + TBranch *b_MuonCand_innerTrackVtxz; //! + TBranch *b_nPrimVertexCand; //! + TBranch *b_PrimVertexCand_x; //! + TBranch *b_PrimVertexCand_y; //! + TBranch *b_PrimVertexCand_z; //! + TBranch *b_PrimVertexCand_chi2; //! + TBranch *b_PrimVertexCand_ndof; //! + TBranch *b_PrimVertexCand_tracks; //! + TBranch *b_nPair; //! + TBranch *b_Pair_lepton1; //! + TBranch *b_Pair_lepton2; //! + TBranch *b_Pair_mass; //! + TBranch *b_Pair_pt; //! + TBranch *b_Pair_eta; //! + TBranch *b_Pair_phi; //! + TBranch *b_Pair_dpt; //! + TBranch *b_Pair_dphi; //! + TBranch *b_Pair_3Dangle; //! + TBranch *b_Pair_extratracks0p5mm; //! + TBranch *b_Pair_extratracks1mm; //! + TBranch *b_Pair_extratracks2mm; //! + TBranch *b_Pair_extratracks3mm; //! + TBranch *b_Pair_extratracks4mm; //! + TBranch *b_Pair_extratracks5mm; //! + TBranch *b_Pair_extratracks1cm; //! + TBranch *b_Pair_extratracks2cm; //! + TBranch *b_Pair_extratracks3cm; //! + TBranch *b_Pair_extratracks4cm; //! + TBranch *b_Pair_extratracks5cm; //! + TBranch *b_Pair_extratracks10cm; //! + TBranch *b_KalmanVertexCand_x; //! + TBranch *b_KalmanVertexCand_y; //! + TBranch *b_KalmanVertexCand_z; //! + TBranch *b_nLocalProtCand; //! + TBranch *b_LocalProtCand_x; //! + TBranch *b_LocalProtCand_y; //! + TBranch *b_LocalProtCand_t; //! + TBranch *b_LocalProtCand_xSigma; //! + TBranch *b_LocalProtCand_ySigma; //! + TBranch *b_LocalProtCand_tSigma; //! + TBranch *b_LocalProtCand_arm; //! + TBranch *b_LocalProtCand_station; //! + TBranch *b_LocalProtCand_pot; //! + TBranch *b_LocalProtCand_rpid; //! + TBranch *b_nRecoProtCand; //! + TBranch *b_ProtCand_xi; //! + TBranch *b_ProtCand_t; //! + TBranch *b_ProtCand_ThX; //! + TBranch *b_ProtCand_ThY; //! + TBranch *b_ProtCand_rpid; //! + TBranch *b_ProtCand_arm; //! + TBranch *b_ProtCand_ismultirp; //! + TBranch *b_nExtraTracks; //! + TBranch *b_ExtraTrack_pair; //! + TBranch *b_ExtraTrack_purity; //! + TBranch *b_ExtraTrack_nhits; //! + TBranch *b_ExtraTrack_charge; //! + TBranch *b_ExtraTrack_ndof; //! + TBranch *b_ExtraTrack_px; //! + TBranch *b_ExtraTrack_py; //! + + Dimuons2017Macro(TTree *tree=0); + virtual ~Dimuons2017Macro(); + virtual Int_t Cut(Long64_t entry); + virtual Int_t GetEntry(Long64_t entry); + virtual Long64_t LoadTree(Long64_t entry); + virtual void Init(TTree *tree); + virtual void Loop(); + virtual Bool_t Notify(); + virtual void Show(Long64_t entry = -1); +}; + +#endif + +#ifdef Dimuons2017Macro_cxx +Dimuons2017Macro::Dimuons2017Macro(TTree *tree) : fChain(0) +{ +// if parameter tree is not specified (or zero), connect the file +// used to generate this class and read the Tree. + if (tree == 0) { + +#ifdef SINGLE_TREE + // The following code should be used if you want this class to access + // a single tree instead of a chain + TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017F_merge.root"); + if (!f || !f->IsOpen()) { + f = new TFile("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017F_merge.root"); + } + f->GetObject("ggll_aod/ntp1",tree); + +#else // SINGLE_TREE + + // The following code should be used if you want this class to access a chain + // of trees. + TChain * chain = new TChain("ggll_aod/ntp1",""); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_LPAIRmumuElastic_Summer17_Pt50_xangle130_divergence30.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017B_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017C_merge_final.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017D_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017E_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017F_merge.root/ggll_aod/ntp1"); + + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2018/ProtonReconstruction_DoubleMu2018B_merge.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2018/ProtonReconstruction_DoubleMu2018C_merge.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2018/ProtonReconstruction_DoubleMu2018D_merge.root/ggll_aod/ntp1"); + + tree = chain; +#endif // SINGLE_TREE + + } + Init(tree); +} + +Dimuons2017Macro::~Dimuons2017Macro() +{ + if (!fChain) return; + delete fChain->GetCurrentFile(); +} + +Int_t Dimuons2017Macro::GetEntry(Long64_t entry) +{ +// Read contents of entry. + if (!fChain) return 0; + return fChain->GetEntry(entry); +} +Long64_t Dimuons2017Macro::LoadTree(Long64_t entry) +{ +// Set the environment to read one entry + if (!fChain) return -5; + Long64_t centry = fChain->LoadTree(entry); + if (centry < 0) return centry; + if (fChain->GetTreeNumber() != fCurrent) { + fCurrent = fChain->GetTreeNumber(); + Notify(); + } + return centry; +} + +void Dimuons2017Macro::Init(TTree *tree) +{ + // The Init() function is called when the selector needs to initialize + // a new tree or chain. Typically here the branch addresses and branch + // pointers of the tree will be set. + // It is normally not necessary to make changes to the generated + // code, but the routine can be extended by the user if needed. + // Init() will be called many times when running on PROOF + // (once per file to be processed). + + // Set object pointer + HLT_Name = 0; + // Set branch addresses and branch pointers + if (!tree) return; + fChain = tree; + fCurrent = -1; + fChain->SetMakeClass(1); + + fChain->SetBranchAddress("Run", &Run, &b_Run); + fChain->SetBranchAddress("LumiSection", &LumiSection, &b_LumiSection); + fChain->SetBranchAddress("BX", &BX, &b_BX); + fChain->SetBranchAddress("EventNum", &EventNum, &b_EventNum); + fChain->SetBranchAddress("nHLT", &nHLT, &b_nHLT); + fChain->SetBranchAddress("HLT_Accept", HLT_Accept, &b_HLT_Accept); + fChain->SetBranchAddress("HLT_Prescl", HLT_Prescl, &b_HLT_Prescl); + fChain->SetBranchAddress("HLT_Name", &HLT_Name, &b_HLT_Name); + fChain->SetBranchAddress("nMuonCand", &nMuonCand, &b_nMuonCand); + fChain->SetBranchAddress("MuonCand_pt", MuonCand_pt, &b_MuonCand_pt); + fChain->SetBranchAddress("MuonCand_eta", MuonCand_eta, &b_MuonCand_eta); + fChain->SetBranchAddress("MuonCand_phi", MuonCand_phi, &b_MuonCand_phi); + fChain->SetBranchAddress("MuonCand_e", MuonCand_e, &b_MuonCand_e); + fChain->SetBranchAddress("MuonCand_charge", MuonCand_charge, &b_MuonCand_charge); + fChain->SetBranchAddress("MuonCand_vtxx", MuonCand_vtxx, &b_MuonCand_vtxx); + fChain->SetBranchAddress("MuonCand_vtxy", MuonCand_vtxy, &b_MuonCand_vtxy); + fChain->SetBranchAddress("MuonCand_vtxz", MuonCand_vtxz, &b_MuonCand_vtxz); + fChain->SetBranchAddress("MuonCand_dxy", MuonCand_dxy, &b_MuonCand_dxy); + fChain->SetBranchAddress("MuonCand_nstatseg", MuonCand_nstatseg, &b_MuonCand_nstatseg); + fChain->SetBranchAddress("MuonCand_ntrklayers", MuonCand_ntrklayers, &b_MuonCand_ntrklayers); + fChain->SetBranchAddress("MuonCand_npxlhits", MuonCand_npxlhits, &b_MuonCand_npxlhits); + fChain->SetBranchAddress("MuonCand_isglobal", MuonCand_isglobal, &b_MuonCand_isglobal); + fChain->SetBranchAddress("MuonCand_istracker", MuonCand_istracker, &b_MuonCand_istracker); + fChain->SetBranchAddress("MuonCand_isstandalone", MuonCand_isstandalone, &b_MuonCand_isstandalone); + fChain->SetBranchAddress("MuonCand_ispfmuon", MuonCand_ispfmuon, &b_MuonCand_ispfmuon); + fChain->SetBranchAddress("MuonCand_istight", MuonCand_istight, &b_MuonCand_istight); + fChain->SetBranchAddress("MuonCandTrack_nmuchits", MuonCandTrack_nmuchits, &b_MuonCandTrack_nmuchits); + fChain->SetBranchAddress("MuonCandTrack_chisq", MuonCandTrack_chisq, &b_MuonCandTrack_chisq); + fChain->SetBranchAddress("MuonCand_innerTrackPt", MuonCand_innerTrackPt, &b_MuonCand_innerTrackPt); + fChain->SetBranchAddress("MuonCand_innerTrackEta", MuonCand_innerTrackEta, &b_MuonCand_innerTrackEta); + fChain->SetBranchAddress("MuonCand_innerTrackPhi", MuonCand_innerTrackPhi, &b_MuonCand_innerTrackPhi); + fChain->SetBranchAddress("MuonCand_innerTrackVtxz", MuonCand_innerTrackVtxz, &b_MuonCand_innerTrackVtxz); + fChain->SetBranchAddress("nPrimVertexCand", &nPrimVertexCand, &b_nPrimVertexCand); + fChain->SetBranchAddress("PrimVertexCand_x", PrimVertexCand_x, &b_PrimVertexCand_x); + fChain->SetBranchAddress("PrimVertexCand_y", PrimVertexCand_y, &b_PrimVertexCand_y); + fChain->SetBranchAddress("PrimVertexCand_z", PrimVertexCand_z, &b_PrimVertexCand_z); + fChain->SetBranchAddress("PrimVertexCand_chi2", PrimVertexCand_chi2, &b_PrimVertexCand_chi2); + fChain->SetBranchAddress("PrimVertexCand_ndof", PrimVertexCand_ndof, &b_PrimVertexCand_ndof); + fChain->SetBranchAddress("PrimVertexCand_tracks", PrimVertexCand_tracks, &b_PrimVertexCand_tracks); + fChain->SetBranchAddress("nPair", &nPair, &b_nPair); + fChain->SetBranchAddress("Pair_lepton1", Pair_lepton1, &b_Pair_lepton1); + fChain->SetBranchAddress("Pair_lepton2", Pair_lepton2, &b_Pair_lepton2); + fChain->SetBranchAddress("Pair_mass", Pair_mass, &b_Pair_mass); + fChain->SetBranchAddress("Pair_pt", Pair_pt, &b_Pair_pt); + fChain->SetBranchAddress("Pair_eta", Pair_eta, &b_Pair_eta); + fChain->SetBranchAddress("Pair_phi", Pair_phi, &b_Pair_phi); + fChain->SetBranchAddress("Pair_dpt", Pair_dpt, &b_Pair_dpt); + fChain->SetBranchAddress("Pair_dphi", Pair_dphi, &b_Pair_dphi); + fChain->SetBranchAddress("Pair_3Dangle", Pair_3Dangle, &b_Pair_3Dangle); + fChain->SetBranchAddress("Pair_extratracks0p5mm", Pair_extratracks0p5mm, &b_Pair_extratracks0p5mm); + fChain->SetBranchAddress("Pair_extratracks1mm", Pair_extratracks1mm, &b_Pair_extratracks1mm); + fChain->SetBranchAddress("Pair_extratracks2mm", Pair_extratracks2mm, &b_Pair_extratracks2mm); + fChain->SetBranchAddress("Pair_extratracks3mm", Pair_extratracks3mm, &b_Pair_extratracks3mm); + fChain->SetBranchAddress("Pair_extratracks4mm", Pair_extratracks4mm, &b_Pair_extratracks4mm); + fChain->SetBranchAddress("Pair_extratracks5mm", Pair_extratracks5mm, &b_Pair_extratracks5mm); + fChain->SetBranchAddress("Pair_extratracks1cm", Pair_extratracks1cm, &b_Pair_extratracks1cm); + fChain->SetBranchAddress("Pair_extratracks2cm", Pair_extratracks2cm, &b_Pair_extratracks2cm); + fChain->SetBranchAddress("Pair_extratracks3cm", Pair_extratracks3cm, &b_Pair_extratracks3cm); + fChain->SetBranchAddress("Pair_extratracks4cm", Pair_extratracks4cm, &b_Pair_extratracks4cm); + fChain->SetBranchAddress("Pair_extratracks5cm", Pair_extratracks5cm, &b_Pair_extratracks5cm); + fChain->SetBranchAddress("Pair_extratracks10cm", Pair_extratracks10cm, &b_Pair_extratracks10cm); + fChain->SetBranchAddress("KalmanVertexCand_x", KalmanVertexCand_x, &b_KalmanVertexCand_x); + fChain->SetBranchAddress("KalmanVertexCand_y", KalmanVertexCand_y, &b_KalmanVertexCand_y); + fChain->SetBranchAddress("KalmanVertexCand_z", KalmanVertexCand_z, &b_KalmanVertexCand_z); + fChain->SetBranchAddress("nLocalProtCand", &nLocalProtCand, &b_nLocalProtCand); + fChain->SetBranchAddress("LocalProtCand_x", LocalProtCand_x, &b_LocalProtCand_x); + fChain->SetBranchAddress("LocalProtCand_y", LocalProtCand_y, &b_LocalProtCand_y); + fChain->SetBranchAddress("LocalProtCand_t", LocalProtCand_t, &b_LocalProtCand_t); + fChain->SetBranchAddress("LocalProtCand_xSigma", LocalProtCand_xSigma, &b_LocalProtCand_xSigma); + fChain->SetBranchAddress("LocalProtCand_ySigma", LocalProtCand_ySigma, &b_LocalProtCand_ySigma); + fChain->SetBranchAddress("LocalProtCand_tSigma", LocalProtCand_tSigma, &b_LocalProtCand_tSigma); + fChain->SetBranchAddress("LocalProtCand_arm", LocalProtCand_arm, &b_LocalProtCand_arm); + fChain->SetBranchAddress("LocalProtCand_station", LocalProtCand_station, &b_LocalProtCand_station); + fChain->SetBranchAddress("LocalProtCand_pot", LocalProtCand_pot, &b_LocalProtCand_pot); + fChain->SetBranchAddress("LocalProtCand_rpid", LocalProtCand_rpid, &b_LocalProtCand_rpid); + fChain->SetBranchAddress("nRecoProtCand", &nRecoProtCand, &b_nRecoProtCand); + fChain->SetBranchAddress("ProtCand_xi", ProtCand_xi, &b_ProtCand_xi); + fChain->SetBranchAddress("ProtCand_t", ProtCand_t, &b_ProtCand_t); + fChain->SetBranchAddress("ProtCand_ThX", ProtCand_ThX, &b_ProtCand_ThX); + fChain->SetBranchAddress("ProtCand_ThY", ProtCand_ThY, &b_ProtCand_ThY); + fChain->SetBranchAddress("ProtCand_rpid", ProtCand_rpid, &b_ProtCand_rpid); + fChain->SetBranchAddress("ProtCand_arm", ProtCand_arm, &b_ProtCand_arm); + fChain->SetBranchAddress("ProtCand_ismultirp", ProtCand_ismultirp, &b_ProtCand_ismultirp); + fChain->SetBranchAddress("nExtraTracks", &nExtraTracks, &b_nExtraTracks); + fChain->SetBranchAddress("ExtraTrack_pair", ExtraTrack_pair, &b_ExtraTrack_pair); + fChain->SetBranchAddress("ExtraTrack_purity", ExtraTrack_purity, &b_ExtraTrack_purity); + fChain->SetBranchAddress("ExtraTrack_nhits", ExtraTrack_nhits, &b_ExtraTrack_nhits); + fChain->SetBranchAddress("ExtraTrack_charge", ExtraTrack_charge, &b_ExtraTrack_charge); + fChain->SetBranchAddress("ExtraTrack_ndof", ExtraTrack_ndof, &b_ExtraTrack_ndof); + fChain->SetBranchAddress("ExtraTrack_px", ExtraTrack_px, &b_ExtraTrack_px); + fChain->SetBranchAddress("ExtraTrack_py", ExtraTrack_py, &b_ExtraTrack_py); + Notify(); +} + +Bool_t Dimuons2017Macro::Notify() +{ + // The Notify() function is called when a new file is opened. This + // can be either for a new TTree in a TChain or when when a new TTree + // is started when using PROOF. It is normally not necessary to make changes + // to the generated code, but the routine can be extended by the + // user if needed. The return value is currently not used. + + return kTRUE; +} + +void Dimuons2017Macro::Show(Long64_t entry) +{ +// Print contents of entry. +// If entry is not specified, print current entry + if (!fChain) return; + fChain->Show(entry); +} +Int_t Dimuons2017Macro::Cut(Long64_t entry) +{ +// This function may be called from Loop. +// returns 1 if entry is accepted. +// returns -1 otherwise. + return 1; +} +#endif // #ifdef Dimuons2017Macro_cxx diff --git a/GammaGammaLeptonLepton/macros/MoreDimuons2017AllWithMultMC.root b/GammaGammaLeptonLepton/macros/MoreDimuons2017AllWithMultMC.root new file mode 100644 index 0000000000000000000000000000000000000000..cc260e0963123ba5efda29fc530ccd07fa1c8595 GIT binary patch literal 21914 zcmeHv2UHVl*KP=*D+1D#s)(RS7mywhMX5H5NK>Q+2oQP?Ac9np-W4fI7myA?1XN0p z-itKpozMa|B++v`|5wiW+q(Cz<63csnYZly>}T({?3uBHLhS*7Wd;BM@E8Elh{ya? zG3Q4=0?f|@ggd$E0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zs6EffZH>+wF?4>lj}n+J<;xg~*4A6;UY>EXuKarS{Bdu|g!Vl`Ld2Od8Un8~#}eNO zMXe3=6{be6b)OE=6KiFE;Ofgp|MHV&>TtY)T&SCcNSd-(d!va?5VUCp9l^u=S$cBc zLC7OSC519!aH_a%sE%9NRk*T_@lOt%VDh>p(k~d(; z^NRN!PjTchsSahaG+_<<_pK+~`r9UXc;KTC6x5XkIqC_j4r2>%Y z{i_;T?;ar5Kgpkry$}^&=lwY53-M=KV_%&Z8G^UU>SS_|M+pR0Y*~KoTba9l;n%Yx zYriM*E#!X|&@zYQu`iJtl!eObp8PV#x=5_(pV(;`8xk6POx(yaRy<7`wh+5o{H&3# z3h6)7{_v$^8tz%s&HzTx&56M|;`j;Lz|K65 z%GD=I0eXN2RqyJ$eju2#sQH1M*ZKx*L??ClCUgxU0dvrcmK zszXG?rzM*7bG1^F9^8%NxR_5J#r1*b*qg}r62X#G3htoX)vU02Ifc_J1475P3FW$$ ziI34O)I=z33*P+p67d#<7y;*uqYUD9op3__#|^xMvBWV zhV46?wLB8bj2S)?RBV<~5AHs&w3ejFjHb5j$*m39?iu~oZuH^7sPm2N!c$V){3|nZ gN4trtM;i+O^553D*w3l{g*7f_37`@0BoYbuKd14L@&Et; literal 0 HcmV?d00001 diff --git a/GammaGammaLeptonLepton/macros/MoreDimuons2017AllWithMultSingleTrack_BCDEF_single_RC.root b/GammaGammaLeptonLepton/macros/MoreDimuons2017AllWithMultSingleTrack_BCDEF_single_RC.root new file mode 100644 index 0000000000000000000000000000000000000000..5ce6e5a3ae3ad9ca0ebd2cea1118c0318836f0d8 GIT binary patch literal 30847 zcmeFZ2UJwqwlxe$&VuBmqM!r`Qsg8kAQ{QIppcvkBqtG2L6Dr22$F;3jFKf3NKxb@ zp~$I#BJ&m4-M9O`zW09jz4!m$c;mHWRGs5FXYak%Tx-uA=AoP&99+=QHdWEk(9F=# z-2G4=8q~Qt>VuB@Bw+qLv2sL1BhEuZuhxBPtA)J2k_AKE^=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->Get("hres56mult"); + + TH1F *h3; + if(reco == 1) + h3 = (TH1F *)f2->Get("hres45"); + if(reco == 2) + h3 = (TH1F *)f2->Get("hres45mult"); + + TH1F *h4; + if(reco == 1) + h4 = (TH1F *)f2->Get("hres56"); + if(reco == 2) + h4 = (TH1F *)f2->Get("hres56mult"); + + + h1->Sumw2(); + h2->Sumw2(); + TH1F *hsum = (TH1F *)h1->Clone("hsum"); + hsum->Sumw2(); + hsum->Add(h2); + + h3->Sumw2(); + h4->Sumw2(); + TH1F *hsummc = (TH1F *)h3->Clone("hsum"); + hsummc->Add(h4); + + TCanvas *c1 = new TCanvas("c1","c1"); + // c1->Divide(1,2); + + // Adjust binning as needed + Int_t rebinfact = 5; + + c1->Divide(3,1); + c1->cd(1); + h3->Rebin(rebinfact); + h1->Rebin(rebinfact); + h3->Scale(1.0/20.0); + h3->SetLineColor(4); h3->SetLineWidth(3); + h1->SetMaximum(100); + h1->Draw("e"); + h3->Draw("histsame"); + TF1 *fitmc1 = new TF1("fitmc1","gaus(0)",-1,1); + TFitResultPtr fitrmc3 = h3->Fit("fitmc1","LEMVS","",-1,1); + + h1->SetStats(1); + h1->SetMarkerStyle(20); h1->SetLineWidth(3); h1->SetLineColor(1); + h1->SetMaximum(100); + h1->SetTitle("2017BCDEF, 45"); + h1->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + h1->Draw("esame"); + TF1 *fit1 = new TF1("fit1", "gaus(0)+pol2(3)",-5,1); + fit1->SetParName(0,"Norm."); + fit1->SetParName(1,"Mean"); + fit1->SetParName(2,"Sigma"); + fit1->SetParName(3,"background p0"); + fit1->SetParName(4,"background p1"); + fit1->SetParName(5,"background p2"); + fit1->SetParameter(0,50); + fit1->SetParameter(1,0); + fit1->SetParameter(2,0.1); + + fit1->SetParLimits(0,0.1,1000); + fit1->SetParLimits(1,-0.5,0.5); + fit1->SetParLimits(2,0.03,0.2); + fit1->SetLineColor(2); + TFitResultPtr fitr = h1->Fit("fit1","LEMVS","",-5,1); + std::cout << fitr->MinFcnValue() << std::endl; + + c1->cd(2); + h2->Rebin(rebinfact); + h4->Rebin(rebinfact); + h4->Scale(1.0/20.0); + h4->SetLineColor(4); h4->SetLineWidth(3); + h4->SetMaximum(100); + h2->Draw("e"); + h4->Draw("histsame"); + TF1 *fitmc2 = new TF1("fitmc2","gaus(0)",-1,1); + TFitResultPtr fitrmc4 = h4->Fit("fitmc2","LEMVS","",-1,1); + + h2->SetStats(1); + h2->SetMarkerStyle(20); h2->SetLineWidth(3); h2->SetLineColor(1); + h2->SetMaximum(100); + h2->SetTitle("2017BCDEF, 56"); + h2->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + h2->Draw("esame"); + TF1 *fit2 = new TF1("fit2", "gaus(0)+pol2(3)",-5,1); + fit2->SetParName(0,"Norm."); + fit2->SetParName(1,"Mean"); + fit2->SetParName(2,"Sigma"); + fit2->SetParName(3,"background p0"); + fit2->SetParName(4,"background p1"); + fit2->SetParName(5,"background p2"); + fit2->SetParameter(0,50); + fit2->SetParameter(1,0); + fit2->SetParameter(2,0.1); + + fit2->SetParLimits(0,0.1,1000); + fit2->SetParLimits(1,-0.5,0.5); + fit2->SetParLimits(2,0.03,0.2); + fit2->SetLineColor(2); + TFitResultPtr fitr2 = h2->Fit("fit2","LEMVS","",-5,1); + std::cout << fitr2->MinFcnValue() << std::endl; + + c1->cd(3); + hsum->Rebin(rebinfact); + hsummc->Rebin(rebinfact); + hsummc->Scale(1.0/20.0); + hsummc->SetLineColor(4); hsummc->SetLineWidth(3); + hsummc->SetMaximum(100); + hsum->Draw("e"); + hsummc->Draw("histsame"); + TF1 *fitmcsum = new TF1("fitmcsum","gaus(0)",-1,1); + TFitResultPtr fitrmcsum = hsummc->Fit("fitmcsum","LEMVS","",-1,1); + + hsum->SetStats(1); + hsum->SetMarkerStyle(20); hsum->SetLineWidth(3); hsum->SetLineColor(1); + hsum->SetMaximum(100); + hsum->SetTitle("2017BCDEF, 45+56"); + hsum->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + hsum->Draw("esame"); + TF1 *fitsum = new TF1("fitsum", "gaus(0)+pol2(3)",-5,1); + fitsum->SetParName(0,"Norm."); + fitsum->SetParName(1,"Mean"); + fitsum->SetParName(2,"Sigma"); + fitsum->SetParName(3,"background p0"); + fitsum->SetParName(4,"background p1"); + fitsum->SetParName(5,"background p2"); + fitsum->SetParameter(0,50); + fitsum->SetParameter(1,0); + fitsum->SetParameter(2,0.10); + + fitsum->SetParLimits(0,0.000001,1000); + fitsum->SetParLimits(1,-0.9,0.9); + fitsum->SetParLimits(2,0.03,0.2); + fitsum->SetLineColor(2); + TFitResultPtr fitrs = hsum->Fit("fitsum","LEMVS","",-5,1); + std::cout << fitrs->MinFcnValue() << std::endl; + + std::cout << "Data:" << std::endl; + std::cout << "\t45 mean = " << fit1->GetParameter(1) << " +- " << fit1->GetParError(1) + << ", sigma = " << fit1->GetParameter(2) << " +- " << fit1->GetParError(2) << std::endl; + std::cout << "\t56 mean = " << fit2->GetParameter(1) << " +- " << fit2->GetParError(1) + << ", sigma = " << fit2->GetParameter(2) << " +- " << fit2->GetParError(2) << std::endl; + std::cout << "\tsum mean = " << fitsum->GetParameter(1) << " +- " << fitsum->GetParError(1) + << ", sigma = " << fitsum->GetParameter(2) << " +- " << fitsum->GetParError(2) << std::endl; + + std::cout << "MC:" << std::endl; + std::cout << "\t45 mean = " << fitmc1->GetParameter(1) << " +- " << fitmc1->GetParError(1) + << ", sigma = " << fitmc1->GetParameter(2) << " +- " << fitmc1->GetParError(2) << std::endl; + std::cout << "\t56 mean = " << fitmc2->GetParameter(1) << " +- " << fitmc2->GetParError(1) + << ", sigma = " << fitmc2->GetParameter(2) << " +- " << fitmc2->GetParError(2) << std::endl; + std::cout << "\tsum mean = " << fitmcsum->GetParameter(1) << " +- " << fitmcsum->GetParError(1) + << ", sigma = " << fitmcsum->GetParameter(2) << " +- " << fitmcsum->GetParError(2) << std::endl; + + std::cout << "\tsum RMS = " << hsummc->GetRMS() << std::endl; + +} + + diff --git a/GammaGammaLeptonLepton/macros/SimpleResolutionFit.C~ b/GammaGammaLeptonLepton/macros/SimpleResolutionFit.C~ new file mode 100644 index 0000000..c328f92 --- /dev/null +++ b/GammaGammaLeptonLepton/macros/SimpleResolutionFit.C~ @@ -0,0 +1,179 @@ +/* + * Simple 1-d fit to Gaussian+polynomial, taking as input the histograms produced by the + * + * + */ +void SimpleResolutionFit(Int_t reco = 1) +{ + TFile *f1 = TFile::Open("MoreDimuons2017AllWithMultSingleTrack_BCDEF_single_RC.root"); + TFile *f2 = TFile::Open("MoreDimuons2017AllWithMultMC.root"); + + TH1F *h1; + if(reco == 1) + h1 = (TH1F *)f1->Get("hres45"); + if(reco == 2) + h1 = (TH1F *)f1->Get("hres45mult"); + + TH1F *h2; + if(reco == 1) + h2 = (TH1F *)f1->Get("hres56"); + if(reco == 2) + h2 = (TH1F *)f1->Get("hres56mult"); + + TH1F *h3; + if(reco == 1) + h3 = (TH1F *)f2->Get("hres45"); + if(reco == 2) + h3 = (TH1F *)f2->Get("hres45mult"); + + TH1F *h4; + if(reco == 1) + h4 = (TH1F *)f2->Get("hres56"); + if(reco == 2) + h4 = (TH1F *)f2->Get("hres56mult"); + + + h1->Sumw2(); + h2->Sumw2(); + TH1F *hsum = (TH1F *)h1->Clone("hsum"); + hsum->Sumw2(); + hsum->Add(h2); + + h3->Sumw2(); + h4->Sumw2(); + TH1F *hsummc = (TH1F *)h3->Clone("hsum"); + hsummc->Add(h4); + + TCanvas *c1 = new TCanvas("c1","c1"); + // c1->Divide(1,2); + + // Adjust binning as needed + Int_t rebinfact = 5; + + c1->Divide(3,1); + c1->cd(1); + h3->Rebin(rebinfact); + h1->Rebin(rebinfact); + h3->Scale(1.0/20.0); + h3->SetLineColor(4); h3->SetLineWidth(3); + h1->SetMaximum(100); + h1->Draw("e"); + h3->Draw("histsame"); + TF1 *fitmc1 = new TF1("fitmc1","gaus(0)",-1,1); + TFitResultPtr fitrmc3 = h3->Fit("fitmc1","LEMVS","",-1,1); + + h1->SetStats(1); + h1->SetMarkerStyle(20); h1->SetLineWidth(3); h1->SetLineColor(1); + h1->SetMaximum(100); + h1->SetTitle("2017BCDEF, 45"); + h1->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + h1->Draw("esame"); + TF1 *fit1 = new TF1("fit1", "gaus(0)+pol2(3)",-5,1); + fit1->SetParName(0,"Norm."); + fit1->SetParName(1,"Mean"); + fit1->SetParName(2,"Sigma"); + fit1->SetParName(3,"background p0"); + fit1->SetParName(4,"background p1"); + fit1->SetParName(5,"background p2"); + fit1->SetParameter(0,50); + fit1->SetParameter(1,0); + fit1->SetParameter(2,0.1); + + fit1->SetParLimits(0,0.1,1000); + fit1->SetParLimits(1,-0.5,0.5); + fit1->SetParLimits(2,0.03,0.2); + fit1->SetLineColor(2); + TFitResultPtr fitr = h1->Fit("fit1","LEMVS","",-5,1); + std::cout << fitr->MinFcnValue() << std::endl; + + c1->cd(2); + h2->Rebin(rebinfact); + h4->Rebin(rebinfact); + h4->Scale(1.0/20.0); + h4->SetLineColor(4); h4->SetLineWidth(3); + h4->SetMaximum(100); + h2->Draw("e"); + h4->Draw("histsame"); + TF1 *fitmc2 = new TF1("fitmc2","gaus(0)",-1,1); + TFitResultPtr fitrmc4 = h4->Fit("fitmc2","LEMVS","",-1,1); + + h2->SetStats(1); + h2->SetMarkerStyle(20); h2->SetLineWidth(3); h2->SetLineColor(1); + h2->SetMaximum(100); + h2->SetTitle("2017BCDEF, 56"); + h2->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + h2->Draw("esame"); + TF1 *fit2 = new TF1("fit2", "gaus(0)+pol2(3)",-5,1); + fit2->SetParName(0,"Norm."); + fit2->SetParName(1,"Mean"); + fit2->SetParName(2,"Sigma"); + fit2->SetParName(3,"background p0"); + fit2->SetParName(4,"background p1"); + fit2->SetParName(5,"background p2"); + fit2->SetParameter(0,50); + fit2->SetParameter(1,0); + fit2->SetParameter(2,0.1); + + fit2->SetParLimits(0,0.1,1000); + fit2->SetParLimits(1,-0.5,0.5); + fit2->SetParLimits(2,0.03,0.2); + fit2->SetLineColor(2); + TFitResultPtr fitr2 = h2->Fit("fit2","LEMVS","",-5,1); + std::cout << fitr2->MinFcnValue() << std::endl; + + c1->cd(3); + hsum->Rebin(rebinfact); + hsummc->Rebin(rebinfact); + hsummc->Scale(1.0/20.0); + hsummc->SetLineColor(4); hsummc->SetLineWidth(3); + hsummc->SetMaximum(100); + hsum->Draw("e"); + hsummc->Draw("histsame"); + TF1 *fitmcsum = new TF1("fitmcsum","gaus(0)",-1,1); + TFitResultPtr fitrmcsum = hsummc->Fit("fitmcsum","LEMVS","",-1,1); + + hsum->SetStats(1); + hsum->SetMarkerStyle(20); hsum->SetLineWidth(3); hsum->SetLineColor(1); + hsum->SetMaximum(100); + hsum->SetTitle("2017BCDEF, 45+56"); + hsum->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + hsum->Draw("esame"); + TF1 *fitsum = new TF1("fitsum", "gaus(0)+pol2(3)",-5,1); + fitsum->SetParName(0,"Norm."); + fitsum->SetParName(1,"Mean"); + fitsum->SetParName(2,"Sigma"); + fitsum->SetParName(3,"background p0"); + fitsum->SetParName(4,"background p1"); + fitsum->SetParName(5,"background p2"); + fitsum->SetParameter(0,50); + fitsum->SetParameter(1,0); + fitsum->SetParameter(2,0.10); + + fitsum->SetParLimits(0,0.000001,1000); + fitsum->SetParLimits(1,-0.9,0.9); + fitsum->SetParLimits(2,0.03,0.2); + fitsum->SetLineColor(2); + TFitResultPtr fitrs = hsum->Fit("fitsum","LEMVS","",-5,1); + std::cout << fitrs->MinFcnValue() << std::endl; + + std::cout << "Data:" << std::endl; + std::cout << "\t45 mean = " << fit1->GetParameter(1) << " +- " << fit1->GetParError(1) + << ", sigma = " << fit1->GetParameter(2) << " +- " << fit1->GetParError(2) << std::endl; + std::cout << "\t56 mean = " << fit2->GetParameter(1) << " +- " << fit2->GetParError(1) + << ", sigma = " << fit2->GetParameter(2) << " +- " << fit2->GetParError(2) << std::endl; + std::cout << "\tsum mean = " << fitsum->GetParameter(1) << " +- " << fitsum->GetParError(1) + << ", sigma = " << fitsum->GetParameter(2) << " +- " << fitsum->GetParError(2) << std::endl; + + std::cout << "MC:" << std::endl; + std::cout << "\t45 mean = " << fitmc1->GetParameter(1) << " +- " << fitmc1->GetParError(1) + << ", sigma = " << fitmc1->GetParameter(2) << " +- " << fitmc1->GetParError(2) << std::endl; + std::cout << "\t56 mean = " << fitmc2->GetParameter(1) << " +- " << fitmc2->GetParError(1) + << ", sigma = " << fitmc2->GetParameter(2) << " +- " << fitmc2->GetParError(2) << std::endl; + std::cout << "\tsum mean = " << fitmcsum->GetParameter(1) << " +- " << fitmcsum->GetParError(1) + << ", sigma = " << fitmcsum->GetParameter(2) << " +- " << fitmcsum->GetParError(2) << std::endl; + + std::cout << "\tsum RMS = " << hsummc->GetRMS() << std::endl; + +} + + diff --git a/GammaGammaLeptonLepton/macros/StupidFit.C~ b/GammaGammaLeptonLepton/macros/StupidFit.C~ new file mode 100644 index 0000000..8525ad0 --- /dev/null +++ b/GammaGammaLeptonLepton/macros/StupidFit.C~ @@ -0,0 +1,573 @@ +void StupidFit(Int_t reco = 1) +{ + // TFile *f1 = TFile::Open("MoreDimuons2017AllWithMultSingleTrack.root"); + // TFile *f1 = TFile::Open("MoreDimuons2017AllWithMultTwoTrack.root"); + // TFile *f1 = TFile::Open("MoreDimuons2017AllWithMultSingleTrackNewFriciCorr2.root"); + // TFile *f1 = TFile::Open("MoreDimuons2017AllWithMultSingleTrackAntiAcopAntiTrackNewFriciCorr3.root"); + // TFile *f1 = TFile::Open("/tmp/jjhollar/MoreDimuons2017AllWithMultSingleTrack.root"); + // TFile *f1 = TFile::Open("/tmp/jjhollar/MoreDimuons2017AllWithMultSingleTrack_single.root"); + // TFile *f1 = TFile::Open("MoreDimuons2017AllWithMultSingleTrackNewFriciCorr3.root"); + // TFile *f1 = TFile::Open("/tmp/jjhollar/MoreDimuons2017AllWithMultSingleTrack_BCDEF_single_RC.root"); + TFile *f1 = TFile::Open("/tmp/jjhollar/MoreDimuons2017AllWithMultSingleTrack_BCDEF_strips.root"); + TFile *f2 = TFile::Open("MoreDimuons2017AllWithMultMC.root"); + + TH1F *h1; + if(reco == 1) + h1 = (TH1F *)f1->Get("hres45"); + if(reco == 2) + h1 = (TH1F *)f1->Get("hres45mult"); + + TH1F *h2; + if(reco == 1) + h2 = (TH1F *)f1->Get("hres56"); + if(reco == 2) + h2 = (TH1F *)f1->Get("hres56mult"); + + TH1F *h3; + if(reco == 1) + h3 = (TH1F *)f2->Get("hres45"); + if(reco == 2) + h3 = (TH1F *)f2->Get("hres45mult"); + + TH1F *h4; + if(reco == 1) + h4 = (TH1F *)f2->Get("hres56"); + if(reco == 2) + h4 = (TH1F *)f2->Get("hres56mult"); + + + h1->Sumw2(); + h2->Sumw2(); + TH1F *hsum = (TH1F *)h1->Clone("hsum"); + hsum->Sumw2(); + hsum->Add(h2); + + h3->Sumw2(); + h4->Sumw2(); + TH1F *hsummc = (TH1F *)h3->Clone("hsum"); + hsummc->Add(h4); + + TCanvas *c1 = new TCanvas("c1","c1"); + // c1->Divide(1,2); + + Int_t rebinfact = 5; + // rebinfact = 6; + // rebinfact = 4; + + // rebinfact = 1; + // For multi-RP + // rebinfact = 3; + + c1->Divide(3,1); + c1->cd(1); + h3->Rebin(rebinfact); + h1->Rebin(rebinfact); + h3->Scale(1.0/20.0); + h3->SetLineColor(4); h3->SetLineWidth(3); + h1->SetMaximum(100); + h1->Draw("e"); + h3->Draw("histsame"); + TF1 *fitmc1 = new TF1("fitmc1","gaus(0)",-1,1); + TFitResultPtr fitrmc3 = h3->Fit("fitmc1","LEMVS","",-1,1); + + // h1->Rebin(2); + h1->SetStats(1); + h1->SetMarkerStyle(20); h1->SetLineWidth(3); h1->SetLineColor(1); + h1->SetMaximum(100); + h1->SetTitle("2017BCDEF, 45"); + h1->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + h1->Draw("esame"); + TF1 *fit1 = new TF1("fit1", "gaus(0)+pol2(3)",-5,1); + fit1->SetParName(0,"Norm."); + fit1->SetParName(1,"Mean"); + fit1->SetParName(2,"Sigma"); + fit1->SetParName(3,"background p0"); + fit1->SetParName(4,"background p1"); + fit1->SetParName(5,"background p2"); + fit1->SetParameter(0,50); + fit1->SetParameter(1,0); + fit1->SetParameter(2,0.1); + + fit1->SetParLimits(0,0.1,1000); + fit1->SetParLimits(1,-0.5,0.5); + fit1->SetParLimits(2,0.03,0.2); + fit1->SetLineColor(2); + TFitResultPtr fitr = h1->Fit("fit1","LEMVS","",-5,1); + std::cout << fitr->MinFcnValue() << std::endl; + + c1->cd(2); + h2->Rebin(rebinfact); + h4->Rebin(rebinfact); + h4->Scale(1.0/20.0); + h4->SetLineColor(4); h4->SetLineWidth(3); + h4->SetMaximum(100); + h2->Draw("e"); + h4->Draw("histsame"); + TF1 *fitmc2 = new TF1("fitmc2","gaus(0)",-1,1); + TFitResultPtr fitrmc4 = h4->Fit("fitmc2","LEMVS","",-1,1); + + // h2->Rebin(2); + h2->SetStats(1); + h2->SetMarkerStyle(20); h2->SetLineWidth(3); h2->SetLineColor(1); + h2->SetMaximum(100); + h2->SetTitle("2017BCDEF, 56"); + h2->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + h2->Draw("esame"); + TF1 *fit2 = new TF1("fit2", "gaus(0)+pol2(3)",-5,1); + fit2->SetParName(0,"Norm."); + fit2->SetParName(1,"Mean"); + fit2->SetParName(2,"Sigma"); + fit2->SetParName(3,"background p0"); + fit2->SetParName(4,"background p1"); + fit2->SetParName(5,"background p2"); + // JH - for multi-RP + fit2->SetParameter(0,10); + // fit2->SetParameter(0,50); + fit2->SetParameter(1,0); + fit2->SetParameter(2,0.1); + + fit2->SetParLimits(0,0.1,1000); + fit2->SetParLimits(1,-0.5,0.5); + fit2->SetParLimits(2,0.03,0.2); + fit2->SetLineColor(2); + TFitResultPtr fitr2 = h2->Fit("fit2","LEMVS","",-5,1); + std::cout << fitr2->MinFcnValue() << std::endl; + + c1->cd(3); + hsum->Rebin(rebinfact); + hsummc->Rebin(rebinfact); + hsummc->Scale(1.0/20.0); + hsummc->SetLineColor(4); hsummc->SetLineWidth(3); + hsummc->SetMaximum(100); + hsum->Draw("e"); + hsummc->Draw("histsame"); + TF1 *fitmcsum = new TF1("fitmcsum","gaus(0)",-1,1); + TFitResultPtr fitrmcsum = hsummc->Fit("fitmcsum","LEMVS","",-1,1); + + hsum->SetStats(1); + hsum->SetMarkerStyle(20); hsum->SetLineWidth(3); hsum->SetLineColor(1); + hsum->SetMaximum(100); + hsum->SetTitle("2017BCDEF, 45+56"); + hsum->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + hsum->Draw("esame"); + TF1 *fitsum = new TF1("fitsum", "gaus(0)+pol2(3)",-5,1); + fitsum->SetParName(0,"Norm."); + fitsum->SetParName(1,"Mean"); + fitsum->SetParName(2,"Sigma"); + fitsum->SetParName(3,"background p0"); + fitsum->SetParName(4,"background p1"); + fitsum->SetParName(5,"background p2"); + fitsum->SetParameter(0,50); + fitsum->SetParameter(1,0); + fitsum->SetParameter(2,0.10); + + fitsum->SetParLimits(0,0.000001,1000); + fitsum->SetParLimits(1,-0.9,0.9); + fitsum->SetParLimits(2,0.03,0.2); + fitsum->SetLineColor(2); + TFitResultPtr fitrs = hsum->Fit("fitsum","LEMVS","",-5,1); + std::cout << fitrs->MinFcnValue() << std::endl; + + std::cout << "Data:" << std::endl; + std::cout << "\t45 mean = " << fit1->GetParameter(1) << " +- " << fit1->GetParError(1) + << ", sigma = " << fit1->GetParameter(2) << " +- " << fit1->GetParError(2) << std::endl; + std::cout << "\t56 mean = " << fit2->GetParameter(1) << " +- " << fit2->GetParError(1) + << ", sigma = " << fit2->GetParameter(2) << " +- " << fit2->GetParError(2) << std::endl; + std::cout << "\tsum mean = " << fitsum->GetParameter(1) << " +- " << fitsum->GetParError(1) + << ", sigma = " << fitsum->GetParameter(2) << " +- " << fitsum->GetParError(2) << std::endl; + + std::cout << "MC:" << std::endl; + std::cout << "\t45 mean = " << fitmc1->GetParameter(1) << " +- " << fitmc1->GetParError(1) + << ", sigma = " << fitmc1->GetParameter(2) << " +- " << fitmc1->GetParError(2) << std::endl; + std::cout << "\t56 mean = " << fitmc2->GetParameter(1) << " +- " << fitmc2->GetParError(1) + << ", sigma = " << fitmc2->GetParameter(2) << " +- " << fitmc2->GetParError(2) << std::endl; + std::cout << "\tsum mean = " << fitmcsum->GetParameter(1) << " +- " << fitmcsum->GetParError(1) + << ", sigma = " << fitmcsum->GetParameter(2) << " +- " << fitmcsum->GetParError(2) << std::endl; + + std::cout << "\tsum RMS = " << hsummc->GetRMS() << std::endl; + /* + c1->cd(4); + // h3->Rebin(rebinfact); + h3->Fit("gaus"); + h3->SetMaximum(100); + h3->Draw("hist"); + + c1->cd(5); + // h4->Rebin(rebinfact); + h4->Fit("gaus"); + h4->SetMaximum(100); + h4->Draw("hist"); + + // c1->cd(2); + c1->cd(6); + // hsummc->Rebin(rebinfact); + hsummc->Fit("gaus"); + hsummc->SetMaximum(100); + hsummc->Draw("hist"); + */ +} + +void StupidFitBins() +{ + TFile *f1 = TFile::Open("MoreDimuons2017AllWithMultSingleTrack.root"); + TH1F *h145= (TH1F *)f1->Get("hbin145"); + TH1F *h245= (TH1F *)f1->Get("hbin245"); + TH1F *h345= (TH1F *)f1->Get("hbin345"); + TH1F *h156= (TH1F *)f1->Get("hbin156"); + TH1F *h256= (TH1F *)f1->Get("hbin256"); + TH1F *h356= (TH1F *)f1->Get("hbin356"); + + Float_t thebins[4] = {0.02,0.03,0.04,0.15}; + + TH1F *hscale45 = new TH1F("hscale45","hscale45",3,thebins); + TH1F *hres45 = new TH1F("hres45","hres45",3,thebins); + TH1F *hscale56 = new TH1F("hscale56","hscale56",3,thebins); + TH1F *hres56 = new TH1F("hres56","hres56",3,thebins); + + // From single-gaussian fit to LPAIR elastics + TH1F *hmcscale45 = new TH1F("hmcscale45","hmcscale45",3,thebins); + TH1F *hmcres45 = new TH1F("hmcres45","hmcres45",3,thebins); + TH1F *hmcscale56 = new TH1F("hmcscale56","hmcscale56",3,thebins); + TH1F *hmcres56 = new TH1F("hmcres56","hmcres56",3,thebins); + hmcscale45->SetBinContent(1,-0.026); hmcscale45->SetBinError(1,0.0081); + hmcscale45->SetBinContent(2,-0.019); hmcscale45->SetBinError(2,0.001); + hmcscale45->SetBinContent(3,-0.004); hmcscale45->SetBinError(3,0.0076); + + // hmcscale56->SetBinContent(1,-0.0196); hmcscale56->SetBinError(1,0.011); + hmcscale56->SetBinContent(2,-0.014); hmcscale56->SetBinError(2,0.0063); + hmcscale56->SetBinContent(3,-0.012); hmcscale56->SetBinError(3,0.013); + + hmcres45->SetBinContent(1,0.081); hmcres45->SetBinError(1,0.009); + hmcres45->SetBinContent(2,0.111); hmcres45->SetBinError(2,0.0099); + hmcres45->SetBinContent(3,0.130); hmcres45->SetBinError(3,0.0064); + + // hmcres56->SetBinContent(1,0.191); hmcres56->SetBinError(1,0.249); + hmcres56->SetBinContent(2,0.1594); hmcres56->SetBinError(2,0.00794); + hmcres56->SetBinContent(3,0.213); hmcres56->SetBinError(3,0.012); + + + hscale45->GetYaxis()->SetRangeUser(-1.0,1.0); hscale45->SetMarkerStyle(20); hscale45->SetLineColor(1); hscale45->SetLineWidth(3); + hscale56->GetYaxis()->SetRangeUser(-1.0,1.0); hscale56->SetMarkerStyle(20); hscale56->SetLineColor(1); hscale56->SetLineWidth(3); + hres45->GetYaxis()->SetRangeUser(0.0,0.5); hres45->SetMarkerStyle(20); hres45->SetLineColor(1); hres45->SetLineWidth(3); + hres56->GetYaxis()->SetRangeUser(0.0,0.5); hres56->SetMarkerStyle(20); hres56->SetLineColor(1); hres56->SetLineWidth(3); + + hmcscale45->SetMarkerStyle(21); hmcscale45->SetMarkerColor(2); hmcscale45->SetLineWidth(3); hmcscale45->SetLineColor(2); + hmcscale56->SetMarkerStyle(21); hmcscale56->SetMarkerColor(2); hmcscale56->SetLineWidth(3); hmcscale56->SetLineColor(2); + hmcres45->SetMarkerStyle(21); hmcres45->SetMarkerColor(2); hmcres45->SetLineWidth(3); hmcres45->SetLineColor(2); + hmcres56->SetMarkerStyle(21); hmcres56->SetMarkerColor(2); hmcres56->SetLineWidth(3); hmcres56->SetLineColor(2); + + + TF1 *fit2 = new TF1("fit2", "gaus(0)+pol2(3)",-2,1); + fit2->SetParName(0,"Norm."); + fit2->SetParName(1,"Mean"); + fit2->SetParName(2,"Sigma"); + fit2->SetParName(3,"background p0"); + fit2->SetParName(4,"background p1"); + fit2->SetParName(5,"background p2"); + fit2->SetParameter(0,20); + fit2->SetParameter(1,0.0); + fit2->SetParameter(2,0.1); + + fit2->SetParLimits(0,0.000001,1000); + fit2->SetParLimits(1,-1,1); + fit2->SetParLimits(2,0.05,0.3); + fit2->SetLineColor(2); + + // h245->Sumw2(); h345->Sumw2(); h245->Add(h345); + // h256->Sumw2(); h356->Sumw2(); h345->Add(h356); + + TCanvas *c1 = new TCanvas("c1","c1"); + // c1->Divide(2,2); + c1->Divide(2,3); + c1->cd(1); + h145->Rebin(12); + TFitResultPtr fitrs145 = h145->Fit("fit2","LEMVS","",-2,1); + h145->Draw("e"); + hscale45->SetBinContent(1,fit2->GetParameter(1)); hscale45->SetBinError(1,fit2->GetParError(1)); + hres45->SetBinContent(1,fit2->GetParameter(2)); hres45->SetBinError(1,fit2->GetParError(2)); + + c1->cd(2); + h156->Rebin(12); + TFitResultPtr fitrs156 = h156->Fit("fit2","LEMVS","",-2,1); + h156->Draw("e"); + // hscale56->SetBinContent(1,fit2->GetParameter(1)); hscale56->SetBinError(1,fit2->GetParError(1)); + // hres56->SetBinContent(1,fit2->GetParameter(2)); hres56->SetBinError(1,fit2->GetParError(2)); + + c1->cd(3); + h245->Rebin(12); + TFitResultPtr fitrs245 = h245->Fit("fit2","LEMVS","",-2,1); + h245->Draw("e"); + hscale45->SetBinContent(2,fit2->GetParameter(1)); hscale45->SetBinError(2,fit2->GetParError(1)); + hres45->SetBinContent(2,fit2->GetParameter(2)); hres45->SetBinError(2,fit2->GetParError(2)); + + c1->cd(4); + h256->Rebin(12); + TFitResultPtr fitrs256 = h256->Fit("fit2","LEMVS","",-2,1); + h256->Draw("e"); + hscale56->SetBinContent(2,fit2->GetParameter(1)); hscale56->SetBinError(2,fit2->GetParError(1)); + hres56->SetBinContent(2,fit2->GetParameter(2)); hres56->SetBinError(2,fit2->GetParError(2)); + + c1->cd(5); + h345->Rebin(12); + TFitResultPtr fitrs345 = h345->Fit("fit2","LEMVS","",-2,1); + h345->Draw("e"); + hscale45->SetBinContent(3,fit2->GetParameter(1)); hscale45->SetBinError(3,fit2->GetParError(1)); + hres45->SetBinContent(3,fit2->GetParameter(2)); hres45->SetBinError(3,fit2->GetParError(2)); + + c1->cd(6); + h356->Rebin(12); + TFitResultPtr fitrs356 = h356->Fit("fit2","LEMVS","",-2,1); + h356->Draw("e"); + hscale56->SetBinContent(3,fit2->GetParameter(1)); hscale56->SetBinError(3,fit2->GetParError(1)); + hres56->SetBinContent(3,fit2->GetParameter(2)); hres56->SetBinError(3,fit2->GetParError(2)); + + + TCanvas *c2 = new TCanvas("c2","c2"); + c2->Divide(2,2); + c2->cd(1); + hscale45->Draw("e"); + hmcscale45->Draw("esame"); + c2->cd(2); + hscale56->Draw("e"); + hmcscale56->Draw("esame"); + c2->cd(3); + hres45->Draw("e"); + hmcres45->Draw("esame"); + c2->cd(4); + hres56->Draw("e"); + hmcres56->Draw("esame"); + + + /* + c1->cd(5); + h345->Rebin(10); + TFitResultPtr fitrs345 = h345->Fit("fit2","LEMVS","",-5,1); + h345->Draw("e"); + c1->cd(6); + h356->Rebin(10); + TFitResultPtr fitrs356 = h356->Fit("fit2","LEMVS","",-5,1); + h356->Draw("e"); + */ + +} + + +void StupidFitBinsComb() +{ + // TFile *f1 = TFile::Open("MoreDimuons2017AllWithMultSingleTrack.root"); + TFile *f1 = TFile::Open("MoreDimuons2017AllWithMultSingleTrackNewFriciCorr3.root"); + TH1F *h145= (TH1F *)f1->Get("hbin145"); + TH1F *h245= (TH1F *)f1->Get("hbin245"); + TH1F *h345= (TH1F *)f1->Get("hbin345"); + TH1F *h156= (TH1F *)f1->Get("hbin156"); + TH1F *h256= (TH1F *)f1->Get("hbin256"); + TH1F *h356= (TH1F *)f1->Get("hbin356"); + + // TFile *f1b = TFile::Open("MoreDimuons2017AllWithMultSingleTrackAntiAcopAntiTrack.root"); + TFile *f1b = TFile::Open("MoreDimuons2017AllWithMultSingleTrackAntiAcopAntiTrackNewFriciCorr3.root"); + TH1F *hb145= (TH1F *)f1b->Get("hbin145"); + TH1F *hb245= (TH1F *)f1b->Get("hbin245"); + TH1F *hb345= (TH1F *)f1b->Get("hbin345"); + TH1F *hb156= (TH1F *)f1b->Get("hbin156"); + TH1F *hb256= (TH1F *)f1b->Get("hbin256"); + TH1F *hb356= (TH1F *)f1b->Get("hbin356"); + + Float_t thebins[4] = {0.02,0.03,0.04,0.15}; + TH1F *hscale45 = new TH1F("hscale45","hscale45",3,thebins); + TH1F *hres45 = new TH1F("hres45","hres45",3,thebins); + TH1F *hscale56 = new TH1F("hscale56","hscale56",3,thebins); + TH1F *hres56 = new TH1F("hres56","hres56",3,thebins); + + // From single-gaussian fit to LPAIR elastics + TH1F *hmcscale45 = new TH1F("hmcscale45","hmcscale45",3,thebins); + TH1F *hmcres45 = new TH1F("hmcres45","hmcres45",3,thebins); + TH1F *hmcscale56 = new TH1F("hmcscale56","hmcscale56",3,thebins); + TH1F *hmcres56 = new TH1F("hmcres56","hmcres56",3,thebins); + hmcscale45->SetBinContent(1,-0.026); hmcscale45->SetBinError(1,0.0081); + hmcscale45->SetBinContent(2,-0.019); hmcscale45->SetBinError(2,0.001); + hmcscale45->SetBinContent(3,-0.004); hmcscale45->SetBinError(3,0.0076); + hmcscale56->SetBinContent(2,-0.014); hmcscale56->SetBinError(2,0.0063); + hmcscale56->SetBinContent(3,-0.012); hmcscale56->SetBinError(3,0.013); + hmcres45->SetBinContent(1,0.081); hmcres45->SetBinError(1,0.009); + hmcres45->SetBinContent(2,0.111); hmcres45->SetBinError(2,0.0099); + hmcres45->SetBinContent(3,0.130); hmcres45->SetBinError(3,0.0064); + hmcres56->SetBinContent(2,0.1594); hmcres56->SetBinError(2,0.00794); + hmcres56->SetBinContent(3,0.213); hmcres56->SetBinError(3,0.012); + + hscale45->GetYaxis()->SetRangeUser(-1.0,1.0); hscale45->SetMarkerStyle(20); hscale45->SetLineColor(1); hscale45->SetLineWidth(3); + hscale56->GetYaxis()->SetRangeUser(-1.0,1.0); hscale56->SetMarkerStyle(20); hscale56->SetLineColor(1); hscale56->SetLineWidth(3); + hres45->GetYaxis()->SetRangeUser(0.0,0.5); hres45->SetMarkerStyle(20); hres45->SetLineColor(1); hres45->SetLineWidth(3); + hres56->GetYaxis()->SetRangeUser(0.0,0.5); hres56->SetMarkerStyle(20); hres56->SetLineColor(1); hres56->SetLineWidth(3); + + hmcscale45->SetMarkerStyle(21); hmcscale45->SetMarkerColor(2); hmcscale45->SetLineWidth(3); hmcscale45->SetLineColor(2); + hmcscale56->SetMarkerStyle(21); hmcscale56->SetMarkerColor(2); hmcscale56->SetLineWidth(3); hmcscale56->SetLineColor(2); + hmcres45->SetMarkerStyle(21); hmcres45->SetMarkerColor(2); hmcres45->SetLineWidth(3); hmcres45->SetLineColor(2); + hmcres56->SetMarkerStyle(21); hmcres56->SetMarkerColor(2); hmcres56->SetLineWidth(3); hmcres56->SetLineColor(2); + + + hb145->SetLineColor(6); hb245->SetLineColor(6); hb345->SetLineColor(6); + hb156->SetLineColor(6); hb256->SetLineColor(6); hb356->SetLineColor(6); + h145->Sumw2(); h245->Sumw2(); h345->Sumw2(); + h156->Sumw2(); h256->Sumw2(); h356->Sumw2(); + hb145->Sumw2(); hb245->Sumw2(); hb345->Sumw2(); + hb156->Sumw2(); hb256->Sumw2(); hb356->Sumw2(); + + + TF1 *fit3 = new TF1("fit3", "gaus(0) + pol0(3)",-5,1); + fit3->SetParName(0,"Norm."); + fit3->SetParName(1,"Mean"); + fit3->SetParName(2,"Sigma"); + fit3->SetParameter(0,20); + fit3->SetParameter(1,0.0); + fit3->SetParameter(2,0.3); + fit3->SetParameter(3,0); + + fit3->SetParLimits(0,0.000001,1000); + fit3->SetParLimits(1,-0.5,0.5); + // fit3->SetParLimits(2,0.05,0.5); + fit3->SetParLimits(2,0.05,0.9); + fit3->SetLineColor(2); + + Float_t norms = 0.0; + Float_t normb = 0.0; + + TCanvas *c1 = new TCanvas("c1","c1"); + c1->Divide(2,3); + c1->cd(1); + h145->Rebin(6); hb145->Rebin(6); + norms = h145->Integral(31,38); + normb = hb145->Integral(31,38); + hb145->Scale(norms/normb); + h145->Draw("e"); + hb145->Draw("histsame"); + h145->Add(hb145,-1); + h145->Draw("e"); + TFitResultPtr fitrsc145 = h145->Fit("fit3","LEMVS","",-5,1); + hscale45->SetBinContent(1,fit3->GetParameter(1)); hscale45->SetBinError(1,fit3->GetParError(1)); + hres45->SetBinContent(1,fit3->GetParameter(2)); hres45->SetBinError(1,fit3->GetParError(2)); + + c1->cd(2); + h156->Rebin(6); hb156->Rebin(6); + norms = h156->Integral(31,38); + normb = hb156->Integral(31,38); + hb156->Scale(norms/normb); + h156->Draw("e"); + hb156->Draw("histsame"); + h156->Add(hb156,-1); + h156->Draw("e"); + + + c1->cd(3); + h245->Rebin(6); hb245->Rebin(6); + norms = h245->Integral(31,38); + normb = hb245->Integral(31,38); + hb245->Scale(norms/normb); + h245->Draw("e"); + hb245->Draw("histsame"); + h245->Add(hb245,-1); + h245->Draw("e"); + TFitResultPtr fitrsc245 = h245->Fit("fit3","LEMVS","",-5,1); + hscale45->SetBinContent(2,fit3->GetParameter(1)); hscale45->SetBinError(2,fit3->GetParError(1)); + hres45->SetBinContent(2,fit3->GetParameter(2)); hres45->SetBinError(2,fit3->GetParError(2)); + + c1->cd(4); + h256->Rebin(6); hb256->Rebin(6); + norms = h256->Integral(31,38); + normb = hb256->Integral(31,38); + hb256->Scale(norms/normb); + h256->Draw("e"); + hb256->Draw("histsame"); + h256->Add(hb256,-1); + h256->Draw("e"); + TFitResultPtr fitrsc256 = h256->Fit("fit3","LEMVS","",-5,1); + hscale56->SetBinContent(2,fit3->GetParameter(1)); hscale56->SetBinError(2,fit3->GetParError(1)); + hres56->SetBinContent(2,fit3->GetParameter(2)); hres56->SetBinError(2,fit3->GetParError(2)); + + c1->cd(5); + h345->Rebin(10); hb345->Rebin(10); + // norms = h345->Integral(16,21); + // normb = hb345->Integral(16,21); + norms = h345->Integral(18,23); + normb = hb345->Integral(18,23); + hb345->Scale(norms/normb); + h345->Draw("e"); + hb345->Draw("histsame"); + h345->Add(hb345,-1); + h345->Draw("e"); + TFitResultPtr fitrsc345 = h345->Fit("fit3","","",-5,1); + hscale45->SetBinContent(3,fit3->GetParameter(1)); hscale45->SetBinError(3,fit3->GetParError(1)); + hres45->SetBinContent(3,fit3->GetParameter(2)); hres45->SetBinError(3,fit3->GetParError(2)); + + c1->cd(6); + h356->Rebin(10); hb356->Rebin(10); + norms = h356->Integral(16,21); + normb = hb356->Integral(16,21); + hb356->Scale(norms/normb); + h356->Draw("e"); + hb356->Draw("histsame"); + h356->Add(hb356,-1); + h356->Draw("e"); + TFitResultPtr fitrsc356 = h356->Fit("fit3","","",-5,1); + hscale56->SetBinContent(3,fit3->GetParameter(1)); hscale56->SetBinError(3,fit3->GetParError(1)); + hres56->SetBinContent(3,fit3->GetParameter(2)); hres56->SetBinError(3,fit3->GetParError(2)); + + TCanvas *c2 = new TCanvas("c2","c2"); + c2->Divide(2,2); + c2->cd(1); + hscale45->Draw("e"); + hmcscale45->Draw("esame"); + c2->cd(2); + hscale56->Draw("e"); + hmcscale56->Draw("esame"); + c2->cd(3); + hres45->Draw("e"); + hmcres45->Draw("esame"); + c2->cd(4); + hres56->Draw("e"); + hmcres56->Draw("esame"); + + + /* + TCanvas *c1 = new TCanvas("c1","c1"); + c1->Divide(1,3); + c1->cd(1); + h145->Rebin(6); h156->Rebin(6); + h145->Sumw2(); h156->Sumw2(); h145->Add(h156); + hb145->Rebin(6); hb156->Rebin(6); + hb145->Sumw2(); hb156->Sumw2(); hb145->Add(hb156); + norms = h145->Integral(31,38); + normb = hb145->Integral(31,38); + hb145->Scale(norms/normb); + // h145->Add(hb145,-1); + hb145->Draw("hist"); + // TFitResultPtr fitcrs145 = hb145->Fit("pol2","LEMVS","",-1.5,0.5); + h145->Draw("e"); + hb145->Draw("histsame"); + + c1->cd(2); + h245->Rebin(10); h256->Rebin(10); + h245->Sumw2(); h256->Sumw2(); h245->Add(h256); + hb245->Rebin(10); hb256->Rebin(10); + hb245->Sumw2(); hb256->Sumw2(); hb245->Add(hb256); + norms = h245->Integral(19,23); + normb = hb245->Integral(19,23); + hb245->Scale(norms/normb); + // h245->Add(hb245,-1); + // TFitResultPtr fitcrs245 = hb245->Fit("pol2","LEMVS","",-1.5,0.5); + h245->Draw("e"); + hb245->Draw("histsame"); + + c1->cd(3); + h345->Rebin(12); h356->Rebin(12); + h345->Sumw2(); h356->Sumw2(); h345->Add(h356); + hb345->Rebin(12); hb356->Rebin(12); + hb345->Sumw2(); hb356->Sumw2(); hb345->Add(hb356); + norms = h345->Integral(16,19); + normb = hb345->Integral(16,19); + hb345->Scale(norms/normb); + // h345->Add(hb345,-1); + // TFitResultPtr fitcrs345 = hb345->Fit("pol2","LEMVS","",-1.5,0.5); + h345->Draw("e"); + hb345->Draw("histsame"); + */ +} From eb1a464234f36f0934986c7a6da0c3af3cef9ec1 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 23 Aug 2021 16:11:29 +0200 Subject: [PATCH 4/4] updates from POG paper --- .../macros/Dimuons2017Macro.C | 1380 +++++++++++------ .../macros/Dimuons2017Macro.h | 162 +- .../macros/Dimuons2018Macro.C | 930 +++++++++++ .../macros/Dimuons2018Macro.h | 529 +++++++ .../macros/FitBinnedPlots.C | 620 ++++++++ 5 files changed, 3167 insertions(+), 454 deletions(-) create mode 100644 GammaGammaLeptonLepton/macros/Dimuons2018Macro.C create mode 100644 GammaGammaLeptonLepton/macros/Dimuons2018Macro.h create mode 100644 GammaGammaLeptonLepton/macros/FitBinnedPlots.C diff --git a/GammaGammaLeptonLepton/macros/Dimuons2017Macro.C b/GammaGammaLeptonLepton/macros/Dimuons2017Macro.C index b885c90..cdda261 100644 --- a/GammaGammaLeptonLepton/macros/Dimuons2017Macro.C +++ b/GammaGammaLeptonLepton/macros/Dimuons2017Macro.C @@ -1,444 +1,936 @@ -#define Dimuons2017Macro_cxx -#include "Dimuons2017Macro.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "TH1.h" -#include "TF1.h" -#include "TFile.h" -#include "TH1F.h" -#include "TMath.h" - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "RoccoR.cc" - - -#include -#include -#include - -#include "./align/alignment_classes.h" -#include "./align/fill_info.h" -#include "./align/fill_info.cc" - -using namespace std; -int getXangle(int run,int lumi, const char* filename); - - -void Dimuons2017Macro::Loop() -{ -int preTS2=1; - - - if (fChain == 0) return; - - TH1F *hacop = new TH1F("hacop","hacop",1000,0,0.01); - TH2F *hcorr45 = new TH2F("hcorr45","hcorr45",500,0,0.25,500,0,0.25); - TH2F *hcorr56 = new TH2F("hcorr56","hcorr56",500,0,0.25,500,0,0.25); - - TH1F *hres45 = new TH1F("hres45","hres45",300,-5,1); - TH1F *hres56 = new TH1F("hres56","hres56",300,-5,1); - TH1F *hressum = new TH1F("hressum","hressum",300,-5,1); - - TH1F *hbin145 = new TH1F("hbin145","hbin145",300,-5,1); - TH1F *hbin156 = new TH1F("hbin156","hbin156",300,-5,1); - TH1F *hbin1sum = new TH1F("hbin1sum","hbin1sum",300,-5,1); - TH1F *hbin245 = new TH1F("hbin245","hbin245",300,-5,1); - TH1F *hbin256 = new TH1F("hbin256","hbin256",300,-5,1); - TH1F *hbin2sum = new TH1F("hbin2sum","hbin2sum",300,-5,1); - TH1F *hbin345 = new TH1F("hbin345","hbin345",300,-5,1); - TH1F *hbin356 = new TH1F("hbin356","hbin356",300,-5,1); - TH1F *hbin3sum = new TH1F("hbin3sum","hbin3sum",300,-5,1); - - TH1F *hres45mult = new TH1F("hres45mult","hres45mult",300,-5,1); - TH1F *hres56mult = new TH1F("hres56mult","hres56mult",300,-5,1); - TH1F *hressummult = new TH1F("hressummult","hressummult",300,-5,1); - -RoccoR rc("RoccoR2017.txt"); - - -///////////////////////////////////////// - -// b2 - TFile *f_in_B2_120 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b2_120_murad.root"); - TFile *f_in_B2_130 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b2_130_murad.root"); - TFile *f_in_B2_140 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b2_140_murad.root"); - - TGraph *m_s_x_to_xi_120_l = (TGraph *) f_in_B2_120->Get("XRPH_B6L5_B2"); - TGraph *m_s_x_to_xi_130_l = (TGraph *) f_in_B2_130->Get("XRPH_B6L5_B2"); - TGraph *m_s_x_to_xi_140_l = (TGraph *) f_in_B2_140->Get("XRPH_B6L5_B2"); - - -// b1 - TFile *f_in_B1_120 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b1_120_murad.root"); - TFile *f_in_B1_130 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b1_130_murad.root"); - TFile *f_in_B1_140 = new TFile("./inp/updatedshiftoptics/xi_as_a_function_of_x_graph_b1_140_murad.root"); - - TGraph *m_s_x_to_xi_120_r = (TGraph *) f_in_B1_120->Get("XRPH_B6R5_B1"); - TGraph *m_s_x_to_xi_130_r = (TGraph *) f_in_B1_130->Get("XRPH_B6R5_B1"); - TGraph *m_s_x_to_xi_140_r = (TGraph *) f_in_B1_140->Get("XRPH_B6R5_B1"); - -///////////////////////////////////////// - -double angle=0; - - -TGraph *graph[2]; -graph[0] = new TGraph(); -graph[1] = new TGraph(); - - - AlignmentResults *alignments = NULL; -AlignmentResultsCollection alignmentCollection; -if(preTS2==1) alignmentCollection.Load("./align/collect_alignments_2018_10_26.4.out"); -if(preTS2==0) alignmentCollection.Load("./align/collect_alignments_2018_10_25.5.out"); // post-TS2 -InitFillInfoCollection(); - - - // 0.02-0.05, 0.05-0.075, and 0.075-0.25 - - Int_t nentries = fChain->GetEntries(); - - Long64_t nbytes = 0, nb = 0; - for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; - // if (Cut(ientry) < 0) continue; - - if(jentry % 10000 == 0) - std::cout << "Entry " << jentry << "/" << nentries << std::endl; - - -////////////////////////////////////// -double dataSFa=0; -double dataSFb=0; -double corrMass=0; -dataSFa = rc.kScaleDT(MuonCand_charge[0], MuonCand_pt[0],MuonCand_eta[0],MuonCand_phi[0], 0, 0); -dataSFb = rc.kScaleDT(MuonCand_charge[1], MuonCand_pt[1],MuonCand_eta[1],MuonCand_phi[1], 0, 0); -double pt0cor=MuonCand_pt[0]*dataSFa; -double pt1cor=MuonCand_pt[1]*dataSFb; -TLorentzVector l1; -TLorentzVector l2; - -TLorentzVector mutmp1; -TLorentzVector mutmp2; -mutmp1.SetPtEtaPhiE(MuonCand_pt[0], MuonCand_eta[0], MuonCand_phi[0], MuonCand_e[0]); -mutmp2.SetPtEtaPhiE(MuonCand_pt[1], MuonCand_eta[1], MuonCand_phi[1], MuonCand_e[1]); - -TLorentzVector pair; -double MASS_MU=0.1057; - - l1.SetXYZM(mutmp1.Px()*dataSFa, - - mutmp1.Py()*dataSFa, - - mutmp1.Pz()*dataSFa, - - MASS_MU); - - l2.SetXYZM(mutmp2.Px()*dataSFb, - - mutmp2.Py()*dataSFb, - - mutmp2.Pz()*dataSFb, - - MASS_MU); -pair = l1+l2; -corrMass = pair.M(); - - - - - -///////////////////////////////////////// - if(/*Pair_mass[0]*/corrMass<110.) - continue; - if(/*MuonCand_pt[0]<50 || MuonCand_pt[1]<50*/pt0cor<50. || pt1cor<50.) - continue; - if(MuonCand_istight[0]!=1 || MuonCand_istight[1]!=1) - continue; - if(MuonCand_charge[0] == MuonCand_charge[1]) - continue; - if(1-fabs(Pair_dphi[0])/3.14159 > 0.009) - continue; - if(Pair_extratracks0p5mm[0] > 0) - continue; - -///////////////////// - - - -FillInfo fillInfo; -unsigned int ret = fillInfoCollection.FindByRun(Run, fillInfo); -const auto alignment_it = alignmentCollection.find(fillInfo.alignmentTag); -// alignments = &alignment_it->second; - // aligned=1; - - - -///////////////////////////////////////////////// -double shx_l=0; -double shx_r=0; - unsigned int rpDecId = 23; - shx_l = alignment_it->second.Apply(rpDecId,1,0); - rpDecId = 123; - shx_r = alignment_it->second.Apply(rpDecId,1,0); -double shx_l_s=0; -double shx_r_s=0; - rpDecId = 3; - shx_l_s = alignment_it->second.Apply(rpDecId,1,0); - rpDecId = 103; - shx_r_s = alignment_it->second.Apply(rpDecId,1,0); - - - -double shy_l=0; -double shy_r=0; -// unsigned int - rpDecId = 23; - shy_l = alignment_it->second.Apply(rpDecId,0,1); - rpDecId = 123; - shy_r = alignment_it->second.Apply(rpDecId,0,1); -double shy_l_s=0; -double shy_r_s=0; - rpDecId = 3; - shy_l_s = alignment_it->second.Apply(rpDecId,0,1); - rpDecId = 103; - shy_r_s = alignment_it->second.Apply(rpDecId,0,1); - - - - -/////////////////////// - - - hacop->Fill(1-fabs(Pair_dphi[0])/3.14159); - - Float_t mumuxisol1 = (1.0/13000.0)*((pt0cor*TMath::Exp(MuonCand_eta[0]) + pt1cor*TMath::Exp(MuonCand_eta[1]))); - Float_t mumuxisol2 = (1.0/13000.0)*((pt0cor*TMath::Exp(-1*MuonCand_eta[0]) + pt1cor*TMath::Exp(-1*MuonCand_eta[1]))); - - - Float_t protxi45 = 0.0; - Float_t protxi56 = 0.0; - Float_t mumuxi45 = 0.0; - Float_t mumuxi56 = 0.0; double prot_x_p=0; - Int_t ntrk45 = 0; - Int_t ntrk56 = 0; - -double prot_x_l=0; -double prot_x_r=0; - - for(Int_t p = 0; p < nLocalProtCand; p++) - {//if(ProtCand_ismultirp[p])continue; - - - - - -if(LocalProtCand_rpid[p] == 23) - { prot_x_l=LocalProtCand_x[p]+shx_l/1000.; - ntrk45++; - } - if(LocalProtCand_rpid[p] == 123) - { prot_x_r=LocalProtCand_x[p]+shx_r/1000.; - ntrk56++; - } - - - -/* - if(ProtCand_arm[p] == 0 && ProtCand_ismultirp[p] == 1) - { - protxi45 = ProtCand_xi[p]; - hres45mult->Fill(1 - (protxi45/mumuxisol1)); - hressummult->Fill(1 - (protxi45/mumuxisol1)); - } - - if(ProtCand_arm[p] == 1 && ProtCand_ismultirp[p] == 1) - { - protxi56 = ProtCand_xi[p]; - hres56mult->Fill(1 - (protxi56/mumuxisol2)); - hressummult->Fill(1 - (protxi56/mumuxisol2)); - } -*/ - } - - -///////////////////////////////////////////////////////// - -if(preTS2==1){ -if(ntrk45==1 || ntrk56==1){angle=getXangle(Run, LumiSection , "./inp/xangle_tillTS2_stableonly_cleanup.csv");} -} - - -if(preTS2==0){ -if(ntrk45==1 || ntrk56==1){angle=getXangle(Run, LumiSection , "./inp/xangle_afterTS2_cleanup.csv");} -} - - - if(ntrk45 ==1) - { prot_x_p=prot_x_l; - - protxi45 = fabs(m_s_x_to_xi_120_l->Eval( prot_x_p) + ( ((120.-angle)/(120.-140.))*(m_s_x_to_xi_140_l->Eval( prot_x_p )-m_s_x_to_xi_120_l->Eval( prot_x_p ) )) ); //ProtCand_xi[p]; - //protxi45 = ProtCand_xi[p]; - hcorr45->Fill(protxi45,mumuxisol1); - hres45->Fill(1 - (protxi45/mumuxisol1)); - hressum->Fill(1 - (protxi45/mumuxisol1)); - graph[0]->SetPoint(graph[0]->GetN(), protxi45 , mumuxisol1); - if(mumuxisol1 >= 0.02 && mumuxisol1 < 0.04) - hbin145->Fill(1 - (protxi45/mumuxisol1)); - if(mumuxisol1 >= 0.04 && mumuxisol1 < 0.06) - hbin245->Fill(1 - (protxi45/mumuxisol1)); - if(mumuxisol1 >= 0.07) - hbin345->Fill(1 - (protxi45/mumuxisol1)); - - ntrk45++; - } - if(ntrk56 ==1) - { prot_x_p=prot_x_r; - - - protxi56 = fabs(m_s_x_to_xi_120_r->Eval( prot_x_p) + ( ((120.-angle)/(120.-140.))*(m_s_x_to_xi_140_r->Eval( prot_x_p )-m_s_x_to_xi_120_r->Eval( prot_x_p ) )) ); //ProtCand_xi[p]; - - hcorr56->Fill(protxi56,mumuxisol2); - hres56->Fill(1 - (protxi56/mumuxisol2)); - hressum->Fill(1 - (protxi56/mumuxisol2)); - - - graph[1]->SetPoint(graph[1]->GetN(), protxi56 , mumuxisol2); - - if(mumuxisol2 >= 0.02 && mumuxisol2 < 0.04) - hbin156->Fill(1 - (protxi56/mumuxisol2)); - if(mumuxisol2 >= 0.04 && mumuxisol2 < 0.07) - hbin256->Fill(1 - (protxi56/mumuxisol2)); - if(mumuxisol2 >= 0.07) - hbin356->Fill(1 - (protxi56/mumuxisol2)); - - ntrk56++; - } - - }//loop - - TFile *fx = new TFile("MoreDimuons2017AllWithMultSingleTrack_BCD_single_RC.root","RECREATE"); -graph[0]->SetName("S45_xiRP_xiMUMU"); -// graph[i]->Draw("AP"); - graph[0]->Write(); -graph[1]->SetName("S56_xiRP_xiMUMU"); -// graph[i]->Draw("AP"); - graph[1]->Write(); - - - hacop->Write(); - hcorr45->Write(); - hres45->Write(); - hcorr56->Write(); - hres56->Write(); - hressum->Write(); - hres45mult->Write(); - hres56mult->Write(); - hressummult->Write(); - - hbin145->Write(); - hbin245->Write(); - hbin345->Write(); - - hbin156->Write(); - hbin256->Write(); - hbin356->Write(); - - fx->Write(); -} - - -int run() - { - Dimuons2017Macro m; - m.Loop(); - - return 0; - } - - - - - - -int getXangle(int run, int lumi, const char* filename) - { - TString drun; - TString dfill; - TString dlumi; - TString temp; - -int Xangle=-1; - - TString runs;runs.Form("%d", run); - TString lumis;lumis.Form("%d", lumi); - - - ifstream F; - F.open((const char*)filename); - - //F.clear(); - //F.seekg(0, ios::beg); - int counter=0; - if(F){ - while (!F.eof()) - { - - - F>>drun; - F>>dfill; - F>>dlumi; - F>>temp; - F>>Xangle; -//if(runfill==runlumi && ) - -if( runs == drun && lumis==dlumi ) - { - // cout << "Read: "<< run<<" " << lumi<<" -----> "< +#include +#include + +bool Dimuons2017Macro::FiducalCuts(Float_t trackx220, Float_t tracky220, Int_t arm, Int_t run) +{ + float pixelX0_rotated = 0; + float pixelY0_rotated = 0; + float thex220 = 0.0; + float they220 = 0.0; + float thex210 = 0.0; + float they210 = 0.0; + + + float xmin_45_210, xmin_45_220, ymin_45_210, ymin_45_220, + xmax_45_210, xmax_45_220, ymax_45_210, ymax_45_220, + xmin_56_210, xmin_56_220, ymin_56_210, ymin_56_220, + xmax_56_210, xmax_56_220, ymax_56_210, ymax_56_220; + + thex210 = pixelX0_rotated; + they210 = pixelY0_rotated; + + thex220 = trackx220; + they220 = tracky220; + + + if((run >= 297020) && (run <= 299329)) + { + // 2017B + xmin_45_220 = 1.995; xmax_45_220 = 24.479; ymin_45_220 = -11.098; ymax_45_220 = 4.298; + xmin_56_220 = 2.422; xmax_56_220 = 24.620; ymin_56_220 = -10.698; ymax_56_220 = 4.698; + } + if((run >= 299337) && (run <= 300785)) + { + // 2017C1 + xmin_45_220 = 1.860; xmax_45_220 = 24.334; ymin_45_220 = -11.098; ymax_45_220 = 4.298; + xmin_56_220 = 2.422; xmax_56_220 = 24.620; ymin_56_220 = -10.698; ymax_56_220 = 4.698; + } + if((run >= 300806) && (run <= 302029)) + { + // 2017C2 copied from C1 + xmin_45_220 = 1.860; xmax_45_220 = 24.334; ymin_45_220 = -11.098; ymax_45_220 = 4.298; + xmin_56_220 = 2.422; xmax_56_220 = 24.620; ymin_56_220 = -10.698; ymax_56_220 = 4.698; + } + if((run >= 302030) && (run <= 303434)) + { + // 2017D - copied from C1 + xmin_45_220 = 1.860; xmax_45_220 = 24.334; ymin_45_220 = -11.098; ymax_45_220 = 4.298; + xmin_56_220 = 2.422; xmax_56_220 = 24.620; ymin_56_220 = -10.698; ymax_56_220 = 4.698; + } + if((run >= 303435) && (run <= 304826)) + { + // 2017E + xmin_45_220 = 1.995; xmax_45_220 = 24.479; ymin_45_220 = -10.098; ymax_45_220 = 4.998; + xmin_56_220 = 2.422; xmax_56_220 = 24.620; ymin_56_220 = -9.698; ymax_56_220 = 5.498; + } + if((run >= 304911) && (run <= 305114)) + { + // 2017F1 + xmin_45_220 = 1.995; xmax_45_220 = 24.479; ymin_45_220 = -10.098; ymax_45_220 = 4.998; + xmin_56_220 = 2.422; xmax_56_220 = 24.620; ymin_56_220 = -9.798; ymax_56_220 = 5.398; + } + if((run >= 305178) && (run <= 305902)) + { + // 2017F2 - copied from F1 + xmin_45_220 = 1.995; xmax_45_220 = 24.479; ymin_45_220 = -10.098; ymax_45_220 = 4.998; + xmin_56_220 = 2.422; xmax_56_220 = 24.620; ymin_56_220 = -9.798; ymax_56_220 = 5.398; + } + if((run >= 305965) && (run <= 306462)) + { + // 2017F3 - copied from F1 + xmin_45_220 = 1.995; xmax_45_220 = 24.479; ymin_45_220 = -10.098; ymax_45_220 = 4.998; + xmin_56_220 = 2.422; xmax_56_220 = 24.620; ymin_56_220 = -9.798; ymax_56_220 = 5.398; + } + + + bool pass = false; + + if(arm == 0) + { + if(((thex220 >= xmin_45_220) && (thex220 <= xmax_45_220)) && + ((they220 >= ymin_45_220) && (they220 <= ymax_45_220))) + { + pass = true; + } + } + if(arm == 1) + { + if(((thex220 >= xmin_56_220) && (thex220 <= xmax_56_220)) && + ((they220 >= ymin_56_220) && (they220 <= ymax_56_220))) + { + pass = true; + } + } + + return pass; +} + +float Dimuons2017Macro::MultiRPEffCorr(Float_t trackx210, Float_t tracky210, Float_t trackx220, Float_t tracky220, Int_t arm, Int_t run) +{ + float effcorrpixrad = 1.0; + float effcorrstrrad = 1.0; + float effcorrstrmultitrk = 1.0; + + Int_t theera = 0; + if((run >= 297020) && (run <= 299329)) + theera = 1; // 2017B + if((run >= 299337) && (run <= 300785)) + theera = 2; // 2017C1 + if((run >= 300806) && (run <= 302029)) + theera = 3; // 2017C2 + if((run >= 302030) && (run <= 303434)) + theera = 4; // 2017D + if((run >= 303435) && (run <= 304826)) + theera = 5; // 2017E + if((run >= 304911) && (run <= 305114)) + theera = 6; // 2017F1 + if((run >= 305178) && (run <= 305902)) + theera = 7; // 2017F2 + if((run >= 305965) && (run <= 306462)) + theera = 8; // 2017F3 + + // Rad damage + strips multi-track + if(theera == 1) + { + if(arm == 0) + { + effcorrpixrad = hpixeffB45->GetBinContent(hpixeffB45->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffB45->GetBinContent(hstreffB45->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffB45->GetBinContent(1); + } + if(arm == 1) + { + effcorrpixrad = hpixeffB56->GetBinContent(hpixeffB56->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffB56->GetBinContent(hstreffB56->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffB56->GetBinContent(1); + } + } + if(theera == 2) + { + if(arm == 0) + { + effcorrpixrad = hpixeffC145->GetBinContent(hpixeffC145->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffC145->GetBinContent(hstreffC145->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffC145->GetBinContent(1); + } + if(arm == 1) + { + effcorrpixrad = hpixeffC156->GetBinContent(hpixeffC156->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffC156->GetBinContent(hstreffC156->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffC156->GetBinContent(1); + } + } + if(theera == 3) // Same as C1 until 3+3 results available + { + if(arm == 0) + { + effcorrpixrad = hpixeffC145->GetBinContent(hpixeffC145->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffC245->GetBinContent(hstreffC245->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffC245->GetBinContent(1); + } + if(arm == 1) + { + effcorrpixrad = hpixeffC156->GetBinContent(hpixeffC156->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffC256->GetBinContent(hstreffC256->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffC256->GetBinContent(1); + } + } + if(theera == 4) // Same as C1 until 3+3 results available + { + if(arm == 0) + { + effcorrpixrad = hpixeffC145->GetBinContent(hpixeffC145->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffD45->GetBinContent(hstreffD45->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffD45->GetBinContent(1); + } + if(arm == 1) + { + effcorrpixrad = hpixeffC156->GetBinContent(hpixeffC156->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffD56->GetBinContent(hstreffD56->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffD56->GetBinContent(1); + } + } + if(theera == 5) + { + if(arm == 0) + { + effcorrpixrad = hpixeffE45->GetBinContent(hpixeffE45->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffE45->GetBinContent(hstreffE45->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffE45->GetBinContent(1); + } + if(arm == 1) + { + effcorrpixrad = hpixeffE56->GetBinContent(hpixeffE56->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffE56->GetBinContent(hstreffE56->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffE56->GetBinContent(1); + } + } + if(theera == 6) + { + if(arm == 0) + { + effcorrpixrad = hpixeffF145->GetBinContent(hpixeffF145->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffF145->GetBinContent(hstreffF145->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffF145->GetBinContent(1); + } + if(arm == 1) + { + effcorrpixrad = hpixeffF156->GetBinContent(hpixeffF156->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffF156->GetBinContent(hstreffF156->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffF156->GetBinContent(1); + } + } + if(theera == 7) // Same as F1 until 3+3 results available + { + if(arm == 0) + { + effcorrpixrad = hpixeffF145->GetBinContent(hpixeffF145->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffF245->GetBinContent(hstreffF245->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffF245->GetBinContent(1); + } + if(arm == 1) + { + effcorrpixrad = hpixeffF156->GetBinContent(hpixeffF156->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffF256->GetBinContent(hstreffF256->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffF256->GetBinContent(1); + } + } + if(theera == 8) // Same as F1 until 3+3 results available + { + if(arm == 0) + { + effcorrpixrad = hpixeffF145->GetBinContent(hpixeffF145->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffF345->GetBinContent(hstreffF345->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffF345->GetBinContent(1); + } + if(arm == 1) + { + effcorrpixrad = hpixeffF156->GetBinContent(hpixeffF156->FindBin(trackx220,tracky220)); + effcorrstrrad = hstreffF356->GetBinContent(hstreffF356->FindBin(trackx210,tracky210)); + effcorrstrmultitrk = hmultistreffF356->GetBinContent(1); + } + } + + + float efftotal = (effcorrpixrad*effcorrstrrad*effcorrstrmultitrk); + + return efftotal; +} + +void Dimuons2017Macro::Loop(Int_t multi, Int_t mc, Int_t sb, Int_t yr, Int_t nearfar) +{ +// In a ROOT session, you can do: +// root> .L Dimuons2017Macro.C +// root> Dimuons2017Macro t +// root> t.GetEntry(12); // Fill t data members with entry number 12 +// root> t.Show(); // Show values of entry 12 +// root> t.Show(16); // Read and show values of entry 16 +// root> t.Loop(); // Loop on all entries +// + +// This is the loop skeleton where: +// jentry is the global entry number in the chain +// ientry is the entry number in the current Tree +// Note that the argument to GetEntry must be: +// jentry for TChain::GetEntry +// ientry for TTree::GetEntry and TBranch::GetEntry +// +// To read only selected branches, Insert statements like: +// METHOD1: +// fChain->SetBranchStatus("*",0); // disable all branches +// fChain->SetBranchStatus("branchname",1); // activate branchname +// METHOD2: replace line +// fChain->GetEntry(jentry); //read all branches +//by b_branchname->GetEntry(ientry); //read only this branch + if (fChain == 0) return; + + TH1F *hacop = new TH1F("hacop","hacop",1000,0,0.01); + TH2F *hcorr45 = new TH2F("hcorr45","hcorr45",500,0,0.25,500,0,0.25); + TH2F *hcorr56 = new TH2F("hcorr56","hcorr56",500,0,0.25,500,0,0.25); + + TH2F *hcorrmult45 = new TH2F("hcorrmult45","hcorrmult45",500,0,0.25,500,0,0.25); + TH2F *hcorrmult56 = new TH2F("hcorrmult56","hcorrmult56",500,0,0.25,500,0,0.25); + + + TH1F *hres45 = new TH1F("hres45","hres45",300,-5,1); + TH1F *hres56 = new TH1F("hres56","hres56",300,-5,1); + TH1F *hressum = new TH1F("hressum","hressum",300,-5,1); + + TH1F *hbin145 = new TH1F("hbin145","hbin145",300,-5,1); + TH1F *hbin156 = new TH1F("hbin156","hbin156",300,-5,1); + TH1F *hbin1sum = new TH1F("hbin1sum","hbin1sum",300,-5,1); + TH1F *hbin245 = new TH1F("hbin245","hbin245",300,-5,1); + TH1F *hbin256 = new TH1F("hbin256","hbin256",300,-5,1); + TH1F *hbin2sum = new TH1F("hbin2sum","hbin2sum",300,-5,1); + TH1F *hbin345 = new TH1F("hbin345","hbin345",300,-5,1); + TH1F *hbin356 = new TH1F("hbin356","hbin356",300,-5,1); + TH1F *hbin3sum = new TH1F("hbin3sum","hbin3sum",300,-5,1); + TH1F *hbin445 = new TH1F("hbin445","hbin445",300,-5,1); + TH1F *hbin456 = new TH1F("hbin456","hbin456",300,-5,1); + TH1F *hbin4sum = new TH1F("hbin4sum","hbin4sum",300,-5,1); + + TH1F *hbin3mult45 = new TH1F("hbin3mult45","hbin3mult45",300,-5,1); + TH1F *hbin3mult56 = new TH1F("hbin3mult56","hbin3mult56",300,-5,1); + TH1F *hbin4mult45 = new TH1F("hbin4mult45","hbin4mult45",300,-5,1); + TH1F *hbin4mult56 = new TH1F("hbin4mult56","hbin4mult56",300,-5,1); + + + TH1F *hres45mult = new TH1F("hres45mult","hres45mult",300,-5,1); + TH1F *hres56mult = new TH1F("hres56mult","hres56mult",300,-5,1); + TH1F *hressummult = new TH1F("hressummult","hressummult",300,-5,1); + + TH1F *hres45multgenmu = new TH1F("hres45multgenmu","hres45multgenmu",300,-5,1); + TH1F *hres56multgenmu = new TH1F("hres56multgenmu","hres56multgenmu",300,-5,1); + TH1F *hressummultgenmu = new TH1F("hressummultgenmu","hressummultgenmu",300,-5,1); + + + TH1F *hn45220 = new TH1F("hn45220","hn45220",10,0,10); + TH1F *hn56220 = new TH1F("hn56220","hn56220",10,0,10); + TH1F *hn45mult = new TH1F("hn45mult","hn45mult",10,0,10); + TH1F *hn56mult = new TH1F("hn56mult","hn56mult",10,0,10); + + TH1F *hxi45mult = new TH1F("hxi45mult","hxi45mult",100,0,0.25); + TH1F *hxi56mult = new TH1F("hxi56mult","hxi56mult",100,0,0.25); + TH1F *hxangle45mult = new TH1F("hxangle45mult","hxangle45mult",50,120,170); + TH1F *hxangle56mult = new TH1F("hxangle56mult","hxangle56mult",50,120,170); + TH1F *hxi45single = new TH1F("hxi45single","hxi45single",100,0,0.25); + TH1F *hxi56single = new TH1F("hxi56single","hxi56single",100,0,0.25); + TH1F *hxangle45single = new TH1F("hxangle45single","hxangle45single",50,120,170); + TH1F *hxangle56single = new TH1F("hxangle56single","hxangle56single",50,120,170); + + TH1F *hmresmulti = new TH1F("hmresmulti","hmresmulti",500,-15,5); + TH1F *hmressingle = new TH1F("hmressingle","hmressingle",500,-15,5); + TH1F *hmresmixed = new TH1F("hmresmixed","hmresmixed",500,-15,5); + TH2F *hmcorrmulti = new TH2F("hmcorrmulti","hmcorrmulti",250,0,2500,250,0,2500); + TH2F *hmcorrmixed = new TH2F("hmcorrmixed","hmcorrmixed",250,0,2500,250,0,2500); + TH2F *hmcorrsingle = new TH2F("hmcorrsingle","hmcorrsingle",250,0,2500,250,0,2500); + TH1F *hmmumu = new TH1F("hmmumu","hmmumu",250,0,2500); + TH2F *hycorrmulti = new TH2F("hycorrmulti","hycorrmulti",250,-2.5,2.5,250,-2.5,2.5); + TH2F *hycorrsingle = new TH2F("hycorrsingle","hycorrsingle",250,-2.5,2.5,250,-2.5,2.5); + TH2F *hycorrmixed = new TH2F("hycorrmixed","hycorrmixed",250,-2.5,2.5,250,-2.5,2.5); + TH2F *hdmdysingle = new TH2F("hdmdysingle","hdmdysingle",1000,-500,500,200,-2,2); + + TH1F *hmresycutsingle = new TH1F("hmresycutsingle","hmresycutsingle",500,-15,5); + TH1F *hmresycutmulti = new TH1F("hmresycutmulti","hmresycutmulti",500,-15,5); + TH1F *hmresycutmixed = new TH1F("hmresycutmixed","hmresycutmixed",500,-15,5); + + TH1F *hpzmumumultmatch45 = new TH1F("hpzmumumultmatch45","hpzmumumultmatch45",500,-2000,2000); + TH1F *hpzmumusinglematch45 = new TH1F("hpzmumusinglematch45","hpzmumusinglematch45",500,-2000,2000); + TH1F *hpzmumumultmatch56 = new TH1F("hpzmumumultmatch56","hpzmumumultmatch56",500,-2000,2000); + TH1F *hpzmumusinglematch56 = new TH1F("hpzmumusinglematch56","hpzmumusinglematch56",500,-2000,2000); + TH1F *hpzmumumultantimatch45 = new TH1F("hpzmumumultantimatch45","hpzmumumultantimatch45",500,-2000,2000); + TH1F *hpzmumusingleantimatch45 = new TH1F("hpzmumusingleantimatch45","hpzmumusingleantimatch45",500,-2000,2000); + TH1F *hpzmumumultantimatch56 = new TH1F("hpzmumumultantimatch56","hpzmumumultantimatch56",500,-2000,2000); + TH1F *hpzmumusingleantimatch56 = new TH1F("hpzmumusingleantimatch56","hpzmumusingleantimatch56",500,-2000,2000); + + TH1F *hgenpzmumu = new TH1F("hgenpzmumu","hgenpzmumu",500,-2000,2000); + + TH2F *hxivst45 = new TH2F("hxivst45","hxivst45",500,0,0.25,100,0,5); + TH2F *hxivst56 = new TH2F("hxivst56","hxivst56",500,0,0.25,100,0,5); + + + // 0.02-0.05, 0.05-0.075, and 0.075-0.25 + + ofstream ofs("TextOutputSingleMultiCorr2017.txt"); + ofstream ofs2("TextOutputMultiRPwithFidEffAndYstar2017.txt"); + + ofs2 << "Run,LS,Event,Arm,xing angle,xi(p),xi(mumu),ximatch,t,theta*x,theta*y,y*,eff" << std::endl; + + Int_t nentries = fChain->GetEntries(); + + TLorentzVector mu1,mu2,mumu; + + Int_t usemultitracks = 0; + Int_t ismc = 1; + Int_t issideband = 0; + Int_t year = 2017; + Int_t usenear = 0; + + usemultitracks = multi; + ismc = mc; + issideband = sb; + year = yr; + usenear = nearfar; + + Int_t id45 = 23; + Int_t id56 = 123; + if(usenear == 1) + { + id45 = 3; + id56 = 103; + } + + Long64_t nbytes = 0, nb = 0; + for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; + // if (Cut(ientry) < 0) continue; + + if(jentry % 10000 == 0) + std::cout << "Entry " << jentry << "/" << nentries << std::endl; + + Float_t theacop = 1-fabs(Pair_dphi[0])/3.14159; + + if(Pair_mass[0]<110) + continue; + if(MuonCand_pt[0]<50 || MuonCand_pt[1]<50) + continue; + if(MuonCand_istight[0]!=1 || MuonCand_istight[1]!=1) + continue; + if(MuonCand_charge[0] == MuonCand_charge[1]) + continue; + if((1-fabs(Pair_dphi[0])/3.14159 > 0.009) && (issideband == 0)) + continue; + // if((1-fabs(Pair_dphi[0])/3.14159 <= 0.009) && (issideband == 1)) + if((theacop <= 0.009 || theacop > 0.1) && (issideband == 1)) // JH - testing narrower sideband + continue; + if((Pair_extratracks0p5mm[0] > 0) && (issideband == 0)) + continue; + if((Pair_extratracks0p5mm[0] < 5 || Pair_extratracks0p5mm[0] > 10) && (issideband == 1)) + continue; + + mu1.SetPtEtaPhiE(MuonCand_pt[0],MuonCand_eta[0],MuonCand_phi[0],MuonCand_e[0]); + mu2.SetPtEtaPhiE(MuonCand_pt[1],MuonCand_eta[1],MuonCand_phi[1],MuonCand_e[1]); + mumu = mu1+mu2; + + + hacop->Fill(1-fabs(Pair_dphi[0])/3.14159); + + Float_t mumuxisol1 = (1.0/13000.0)*((MuonCand_pt[0]*TMath::Exp(MuonCand_eta[0]) + MuonCand_pt[1]*TMath::Exp(MuonCand_eta[1]))); + Float_t mumuxisol2 = (1.0/13000.0)*((MuonCand_pt[0]*TMath::Exp(-1*MuonCand_eta[0]) + MuonCand_pt[1]*TMath::Exp(-1*MuonCand_eta[1]))); + + Float_t genmumuxisol1 = (1.0/13000.0)*((GenMuonCand_pt[0]*TMath::Exp(GenMuonCand_eta[0]) + GenMuonCand_pt[1]*TMath::Exp(GenMuonCand_eta[1]))); + Float_t genmumuxisol2 = (1.0/13000.0)*((GenMuonCand_pt[0]*TMath::Exp(-1*GenMuonCand_eta[0]) + GenMuonCand_pt[1]*TMath::Exp(-1*GenMuonCand_eta[1]))); + + + Float_t protxi45 = 0.0; + Float_t protxi56 = 0.0; + Float_t protxi45single = 0.0; + Float_t protxi56single = 0.0; + Float_t protxi45multi = 0.0; + Float_t protxi56multi = 0.0; + Float_t protx45multi210 = 0.0; + Float_t proty45multi210 = 0.0; + Float_t protx45multi220 = 0.0; + Float_t proty45multi220 = 0.0; + Float_t protx56multi210 = 0.0; + Float_t proty56multi210 = 0.0; + Float_t protx56multi220 = 0.0; + Float_t proty56multi220 = 0.0; + + Float_t mumuxi45 = 0.0; + Float_t mumuxi56 = 0.0; + Float_t prott45 = 0.0; + Float_t prott56 = 0.0; + Float_t protthx45 = 0.0; + Float_t protthy45 = 0.0; + Float_t protthx56 = 0.0; + Float_t protthy56 = 0.0; + Float_t protystar45 = 0.0; + Float_t protystar56 = 0.0; + Int_t ntrk45 = 0; + Int_t ntrk56 = 0; + + // JH - do this to select events with only 1 pixel track! + Int_t ncountpixel45 = 0; + Int_t ncountpixel56 = 0; + Int_t ncountmulti45 = 0; + Int_t ncountmulti56 = 0; + + for(Int_t p = 0; p < nRecoProtCand; p++) + { + if(ProtCand_rpid[p] == id45 && ProtCand_ismultirp[p]==0) + ncountpixel45++; + if(ProtCand_rpid[p] == id56 && ProtCand_ismultirp[p]==0) + ncountpixel56++; + if(ProtCand_ismultirp[p]==1 && ProtCand_arm[p]==0) + ncountmulti45++; + if(ProtCand_ismultirp[p]==1 && ProtCand_arm[p]==1) + ncountmulti56++; + } + + hn45220->Fill(ncountpixel45); + hn56220->Fill(ncountpixel56); + hn45mult->Fill(ncountmulti45); + hn56mult->Fill(ncountmulti56); + + + for(Int_t p = 0; p < nRecoProtCand; p++) + { + if(ProtCand_rpid[p] == id45 && ProtCand_ismultirp[p]==0 && ProtCand_trackpixshift1[p] < 1 && ntrk45 < 1 && (ncountpixel45==1 || usemultitracks==1)) + { + protxi45 = ProtCand_xi[p]; + protxi45single = protxi45; + hcorr45->Fill(protxi45,mumuxisol1); + hres45->Fill(1 - (protxi45/mumuxisol1)); + hressum->Fill(1 - (protxi45/mumuxisol1)); + + if(mumuxisol1 >= 0.02 && mumuxisol1 < 0.03) + hbin145->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.03 && mumuxisol1 < 0.04) + hbin245->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.04 && mumuxisol1 < 0.06) + hbin345->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.06) + hbin445->Fill(1 - (protxi45/mumuxisol1)); + + if(fabs(1 - (protxi45/mumuxisol1)) < 0.25) + { + hxi45single->Fill(protxi45); + hpzmumusinglematch45->Fill(mumu.Pz()); + } + else + hpzmumusingleantimatch45->Fill(mumu.Pz()); + + std::cout << "Run, Lumi, Event = " << Run << ", " << LumiSection << ", " << EventNum << std::endl; + std::cout << "\t xi(RP=3) = " << protxi45 << std::endl; + + // ofs << Run << " " << LumiSection << " " << EventNum << " Single 23 " << protxi45 << " " << (1 - (protxi45/mumuxisol1)) << std::endl; + + ntrk45++; + } + if(ProtCand_rpid[p] == id56 && ProtCand_ismultirp[p]==0 && ProtCand_trackpixshift1[p] < 1 && ntrk56 < 1 && (ncountpixel56==1 || usemultitracks==1)) + { + protxi56 = ProtCand_xi[p]; + protxi56single = protxi56; + hcorr56->Fill(protxi56,mumuxisol2); + hres56->Fill(1 - (protxi56/mumuxisol2)); + hressum->Fill(1 - (protxi56/mumuxisol2)); + + if(mumuxisol2 >= 0.02 && mumuxisol2 < 0.03) + hbin156->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.03 && mumuxisol2 < 0.04) + hbin256->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.04 && mumuxisol2 < 0.06) + hbin356->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.06) + hbin456->Fill(1 - (protxi56/mumuxisol2)); + + if(fabs(1 - (protxi56/mumuxisol2)) < 0.25) + { + hxi56single->Fill(protxi56); + hpzmumusinglematch56->Fill(mumu.Pz()); + } + else + hpzmumusingleantimatch56->Fill(mumu.Pz()); + + std::cout << "Run, Lumi, Event = " << Run << " " << LumiSection << " " << EventNum << std::endl; + std::cout << "\t xi(RP=103) = " <Get("2017_preTS2/multi rp-0/g_xi_unc_vs_xi"); + grsyst45 = (TGraphErrors *)fsyst->Get("2017_preTS2/multi rp-0/xi/g_systematics_vs_xi"); + std::cout << "Getting syst. shift for proton with xi = " << protxi45 << std::endl; + float systshift = grsyst45->Eval(protxi45); + std::cout << "xi(orig) = " << protxi45 << " + shift of " << systshift << " (" << systshift/protxi45 << "%)" << std::endl; + protxi45 = protxi45 - systshift; + + // Tracks for eff. correction + protx45multi220 = ProtCand_trackx1[p]; + proty45multi220 = ProtCand_tracky1[p]; + protx45multi210 = ProtCand_trackx2[p]; + proty45multi210 = ProtCand_tracky2[p]; + + // Fiducial cuts + if((FiducalCuts(protx45multi220, proty45multi220, 0, Run) == true) || (ismc == 1)) + { + hres45mult->Fill(1 - (protxi45/mumuxisol1)); + hressummult->Fill(1 - (protxi45/mumuxisol1)); + hcorrmult45->Fill(protxi45,mumuxisol1); + + hressummultgenmu->Fill(1 - (protxi45/genmumuxisol1)); + hres45multgenmu->Fill(1 - (protxi45/genmumuxisol1)); + + if(mumuxisol1 >= 0.04 && mumuxisol1 < 0.06) + hbin3mult45->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.06) + hbin4mult45->Fill(1 - (protxi45/mumuxisol1)); + + std::cout << "Run, Lumi, Event = " << Run << ", " << LumiSection << ", " << EventNum << std::endl; + std::cout << "\t xi(multi arm=45) = " << protxi45 << std::endl; + + if(fabs(1 - (protxi45/mumuxisol1)) < 0.10 && (mumuxisol1 >= 0.04)) + { + hxi45mult->Fill(protxi45); + hxangle45mult->Fill(CrossingAngle); + hpzmumumultmatch45->Fill(mumu.Pz()); + hxivst45->Fill(protxi45,prott45); + + float efficiency = MultiRPEffCorr(protx45multi210, proty45multi210, protx45multi220, proty45multi220, 0, Run); + + ofs2 << Run << "," << LumiSection << "," << EventNum << ",45," << CrossingAngle << "," << protxi45 << "," << mumuxisol1 << "," + << 1 - (protxi45/mumuxisol1) << "," << prott45 + << ", " << protthx45 << ", " << protthy45 << ", " << ", " << protystar45 << ", " << efficiency + << std::endl; + + } + else + hpzmumumultantimatch45->Fill(mumu.Pz()); + } + } + + if(ProtCand_arm[p] == 1 && ProtCand_trackpixshift1[p] < 1 && ProtCand_ismultirp[p] == 1 && (ncountmulti56==1 || usemultitracks==1)) + { + protxi56 = ProtCand_xi[p]; + prott56 = -1.0*ProtCand_t[p]; + protthx56 = ProtCand_ThX[p]; + protthy56 = ProtCand_ThY[p]; + protystar56 = ProtCand_ystar[p]; + protxi56multi = protxi56; + + // JH: shift up 8% + // protxi56multi = protxi56 - (0.08*protxi56); + // JH: shift up by Jan's systematics file + // grsyst56 = (TGraphErrors *)fsyst->Get("2017_preTS2/multi rp-1/g_xi_unc_vs_xi"); + grsyst56 = (TGraphErrors *)fsyst->Get("2017_preTS2/multi rp-1/xi/g_systematics_vs_xi"); + float systshift = grsyst56->Eval(protxi56); + std::cout << "xi(orig) = " << protxi56 << " + shift of " << systshift << " (" << systshift/protxi56 << "%)" << std::endl; + protxi56 = protxi56 - systshift; + + // Tracks for eff. correction + protx56multi220 = ProtCand_trackx1[p]; + proty56multi220 = ProtCand_tracky1[p]; + protx56multi210 = ProtCand_trackx2[p]; + proty56multi210 = ProtCand_tracky2[p]; + + if((FiducalCuts(protx56multi220, proty56multi220, 1, Run) == true) || (ismc == 1)) + { + hres56mult->Fill(1 - (protxi56/mumuxisol2)); + hressummult->Fill(1 - (protxi56/mumuxisol2)); + hcorrmult56->Fill(protxi56,mumuxisol2); + + hressummultgenmu->Fill(1 - (protxi56/genmumuxisol2)); + hres56multgenmu->Fill(1 - (protxi56/genmumuxisol2)); + + + if(mumuxisol2 >= 0.04 && mumuxisol2 < 0.06) + hbin3mult56->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.06) + hbin4mult56->Fill(1 - (protxi56/mumuxisol2)); + + + std::cout << "Run, Lumi, Event = " << Run << ", " << LumiSection << ", " << EventNum << std::endl; + std::cout << "\t xi(multi arm=56) = " << protxi56 << std::endl; + + if((fabs(1 - (protxi56/mumuxisol2)) > -0.05) && (fabs(1 - (protxi56/mumuxisol2)) < 0.20) && (mumuxisol2 >= 0.04)) + { + hxi56mult->Fill(protxi56); + hxangle56mult->Fill(CrossingAngle); + hpzmumumultmatch56->Fill(mumu.Pz()); + hxivst56->Fill(protxi56,prott56); + + float efficiency = MultiRPEffCorr(protx56multi210, proty56multi210, protx56multi220, proty56multi220, 1, Run); + + ofs2 << Run << "," << LumiSection << "," << EventNum << ",56," << CrossingAngle << "," << protxi56 << "," << mumuxisol2 << "," + << 1 - (protxi56/mumuxisol2) << "," << prott56 + << ", " << protthx56 << ", " << protthy56 << ", " << protystar56 << ", " << efficiency + << std::endl; + + } + else + hpzmumumultantimatch56->Fill(mumu.Pz()); + } + } + } + + ofs << Run << " " << LumiSection << " " << EventNum + << " Single 3 " << protxi45single << " " << (1 - (protxi45single/mumuxisol1)) + << " Single 103 " << protxi56single << " " << (1 - (protxi56single/mumuxisol2)) + << " Multi 3 " << protxi45multi << " " << (1 - (protxi45multi/mumuxisol1)) + << " Multi 103 " << protxi56multi << " " << (1 - (protxi56multi/mumuxisol2)) << std::endl; + + Float_t mpp = 0.0; + Float_t ypp = 0.0; + Float_t mmumu = mumu.M(); + Float_t ymumu = mumu.Rapidity(); + + hmmumu->Fill(mmumu); + if(protxi45multi > 0 && protxi56multi > 0) + { + mpp = 13000.0 * TMath::Sqrt(protxi45multi*protxi56multi); + ypp = 0.5 * TMath::Log(protxi45multi/protxi56multi); + std::cout << "mpp(multi) = " << mpp << ", mmumu = " << mmumu << std::endl; + hmresmulti->Fill((1 - (mpp/mmumu))); + hmcorrmulti->Fill(mmumu,mpp); + hycorrmulti->Fill(ymumu,ypp); + if(fabs(ypp-ymumu) < 0.3) + { + hmresycutmulti->Fill((1 - (mpp/mmumu))); + if(fabs(1 - (mpp/mmumu)) < 0.5) + std::cout << "HEY!!! Look at multi-multi event " << Run << ":" << LumiSection << ":" << EventNum + << " with m(mumu) = " << mmumu << ", m(pp) = " << mpp + << ", y(mumu) = " << ymumu << ", y(pp) = " << ypp + << ", xi(45) = " << protxi45multi << ", xi(56) = " << protxi56multi << std::endl; + } + } + if(protxi45multi > 0 && protxi56single > 0) + { + mpp = 13000.0 * TMath::Sqrt(protxi45multi*protxi56single); + ypp =0.5 * TMath::Log(protxi45multi/protxi56single); + std::cout << "mpp(mixed 45multi 56single) = " << mpp << ", mmumu = " << mmumu << std::endl; + hmresmixed->Fill((1 - (mpp/mmumu))); + hmcorrmixed->Fill(mmumu,mpp); + hycorrmixed->Fill(ymumu,ypp); + if(fabs(ypp-ymumu) < 0.3) + { + hmresycutmixed->Fill((1 - (mpp/mmumu))); + if(fabs(1 - (mpp/mmumu)) < 0.5) + std::cout << "HEY!!! Look at multi-sinlge event " << Run << ":" << LumiSection << ":" << EventNum + << " with m(mumu) = " << mmumu << ", m(pp) = " << mpp + << ", y(mumu) = " << ymumu << ", y(pp) = " << ypp + << ", xi(45) = " << protxi45multi << ", xi(56) = " << protxi56single << std::endl; + } + } + if(protxi56multi > 0 && protxi45single > 0) + { + mpp = 13000.0 * TMath::Sqrt(protxi45single*protxi56multi); + ypp =0.5 * TMath::Log(protxi45single/protxi56multi); + std::cout << "mpp(mixed 45single 56multi) = " << mpp << ", mmumu = " << mmumu << std::endl; + hmresmixed->Fill((1 - (mpp/mmumu))); + hmcorrmixed->Fill(mmumu,mpp); + hycorrmixed->Fill(ymumu,ypp); + if(fabs(ypp-ymumu) < 0.3) + { + hmresycutmixed->Fill((1 - (mpp/mmumu))); + if(fabs(1 - (mpp/mmumu)) < 0.5) + std::cout << "HEY!!! Look at single-multi event " << Run << ":" << LumiSection << ":" << EventNum + << " with m(mumu) = " << mmumu << ", m(pp) = " << mpp + << ", y(mumu) = " << ymumu << ", y(pp) = " << ypp + << ", xi(45) = " << protxi45single << ", xi(56) = " << protxi56multi << std::endl; + } + } + if(protxi45single > 0 && protxi56single > 0) + { + mpp = 13000.0 * TMath::Sqrt(protxi45single*protxi56single); + ypp =0.5 * TMath::Log(protxi45single/protxi56single); + std::cout << "mpp(single) = " << mpp << ", mmumu = " << mmumu << std::endl; + std::cout << "ypp(single) = " << ypp << ", ymumu = " << ymumu << std::endl; + hmressingle->Fill((1 - (mpp/mmumu))); + hmcorrsingle->Fill(mmumu,mpp); + hycorrsingle->Fill(ymumu,ypp); + hdmdysingle->Fill(mpp-mmumu,ypp-ymumu); + if(fabs(ypp-ymumu) < 0.3) + { + hmresycutsingle->Fill((1 - (mpp/mmumu))); + if(fabs(1 - (mpp/mmumu)) < 0.5) + std::cout << "HEY!!! Look at single-single event " << Run << ":" << LumiSection << ":" << EventNum + << " with m(mumu) = " << mmumu << ", m(pp) = " << mpp + << ", y(mumu) = " << ymumu << ", y(pp) = " << ypp + << ", xi(45) = " << protxi45single << ", xi(56) = " << protxi56single << std::endl; + } + } + } + + ofs.close(); + ofs2.close(); + + // TFile *fx = new TFile("MoreDimuons2017BCDEFWithMultiLegacyFinalFromDB.root","RECREATE"); + // TFile *fx = new TFile("MoreDimuons2017BCDEFSingleTrackiNearLegacyFinalFromDB.root","RECREATE"); + // TFile *fx = new TFile("MoreDimuons2017BCDEFSingleTrackFarLegacyFinalFromDBWithMass.root","RECREATE"); + + // TFile *fx = new TFile("MoreDimuons2017BCDEFWithMultiTrackFarLegacyFinalFromDBWithMass.root","RECREATE"); + // TFile *fx = new TFile("MoreDimuons2017MCallanglesSingleTrackLegacyFinalFromDB.root","RECREATE"); + // TFile *fx = new TFile("MoreDimuons2017MCallanglesWithMultiLegacyFinalFromDBWithMass.root","RECREATE"); + + TFile *fx; + + if(issideband == 0) + { + if(usemultitracks == 1) + { + if(ismc == 0) + { + if(year == 2017) + fx = new TFile("MoreDimuons2017BCDEFWithMultiTrackFarLegacyFinalFromDBWithMassMoreBins.root","RECREATE"); + if(year == 2018) + { + if(usenear == 0){fx = new TFile("MoreDimuons2018BCDWithMultiTrackFarLegacyFinalFromDBWithMassMoreBins.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2018BCDWithMultiTrackNearLegacyFinalFromDBWithMassMoreBins.root","RECREATE");} + } + } + if(ismc == 1) + { + if(year == 2017) + fx = new TFile("MoreDimuons2017MCallanglesWithMultiLegacyFinalFromDBWithMassMoreBins.root","RECREATE"); + if(year == 2018) + fx = new TFile("MoreDimuons2018MCallanglesWithMultiLegacyFinalFromDBWithMassMoreBins.root","RECREATE"); + } + } + if(usemultitracks == 0) + { + if(ismc == 0) + { + if(year == 2017) + { + if(usenear == 0){fx = new TFile("MoreDimuons2017BCDEFSingleTrackPixelsLegacyFinalFromDBWithMass.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2017BCDEFSingleTrackStripsLegacyFinalFromDBWithMass.root","RECREATE");} + // fx = new TFile("MoreDimuons2017BCDEFSingleTrackStripsLegacyFinalFromDBWithMass.root","RECREATE"); + } + if(year == 2018) + { + if(usenear == 0){fx = new TFile("MoreDimuons2018BCDSingleTrackPixelsFarLegacyFinalFromDBWithMass.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2018BCDSingleTrackPixelsNearLegacyFinalFromDBWithMass.root","RECREATE");} + } + } + if(ismc == 1) + { + if(year == 2017) + fx = new TFile("MoreDimuons2017MCallanglesWithMultiLegacyFinalFromDBWithMass.root","RECREATE"); + if(year == 2018) + fx = new TFile("MoreDimuons2018MCallanglesWithMultiLegacyFinalFromDBWithMass.root","RECREATE"); + } + } + } + if(issideband == 1) + { + if(usemultitracks == 1) + if(ismc == 0) + { + if(year == 2017) + fx = new TFile("MoreDimuons2017BCDEFWithMultiTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracksMoreBins.root","RECREATE"); + if(year == 2018) + { + if(usenear == 0){fx = new TFile("MoreDimuons2018BCDWithMultiTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracksMoreBins.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2018BCDWithMultiTrackNearLegacyFinalFromDBWithMassAntiAcop1to5tracksMoreBins.root","RECREATE");} + } + } + if(usemultitracks == 0) + if(ismc == 0) + { + if(year == 2017) + { + if(usenear == 0){fx = new TFile("MoreDimuons2017BCDEFSingleTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracks.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2017BCDEFSingleTrackNearLegacyFinalFromDBWithMassAntiAcop1to5tracks.root","RECREATE");} + } + if(year == 2018) + { + if(usenear == 0){fx = new TFile("MoreDimuons2018BCDSingleTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracks.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2018BCDSingleTrackNearLegacyFinalFromDBWithMassAntiAcop1to5tracks.root","RECREATE");} + } + } + } + + hacop->Write(); + hcorr45->Write(); + hres45->Write(); + hcorr56->Write(); + hres56->Write(); + hressum->Write(); + hres45mult->Write(); + hres56mult->Write(); + hressummult->Write(); + + hressummultgenmu->Write(); + hres45multgenmu->Write(); + hres56multgenmu->Write(); + + + hbin145->Write(); + hbin245->Write(); + hbin345->Write(); + hbin445->Write(); + + hbin156->Write(); + hbin256->Write(); + hbin356->Write(); + hbin456->Write(); + + hbin3mult45->Write(); + hbin3mult56->Write(); + hbin4mult45->Write(); + hbin4mult56->Write(); + + hn45220->Write(); + hn56220->Write(); + hn45mult->Write(); + hn56mult->Write(); + + hcorrmult45->Write(); + hcorrmult56->Write(); + + hxi45mult->Write(); + hxi56mult->Write(); + hxangle45mult->Write(); + hxangle56mult->Write(); + hxi45single->Write(); + hxi56single->Write(); + + hmresmulti->Write(); + hmresmixed->Write(); + hmressingle->Write(); + hmcorrsingle->Write(); + hmcorrmulti->Write(); + hmcorrmixed->Write(); + + hmmumu->Write(); + hycorrsingle->Write(); + hycorrmulti->Write(); + hycorrmixed->Write(); + hdmdysingle->Write(); + hmresycutmulti->Write(); + hmresycutmixed->Write(); + hmresycutsingle->Write(); + + hpzmumusinglematch45->Write(); + hpzmumusinglematch56->Write(); + hpzmumumultmatch45->Write(); + hpzmumumultmatch56->Write(); + hpzmumusingleantimatch45->Write(); + hpzmumusingleantimatch56->Write(); + hpzmumumultantimatch45->Write(); + hpzmumumultantimatch56->Write(); + + hxivst45->Write(); + hxivst56->Write(); + + fx->Write(); +} diff --git a/GammaGammaLeptonLepton/macros/Dimuons2017Macro.h b/GammaGammaLeptonLepton/macros/Dimuons2017Macro.h index 83ed283..138d73c 100644 --- a/GammaGammaLeptonLepton/macros/Dimuons2017Macro.h +++ b/GammaGammaLeptonLepton/macros/Dimuons2017Macro.h @@ -26,6 +26,7 @@ public : UInt_t LumiSection; UInt_t BX; UInt_t EventNum; + Float_t CrossingAngle; UInt_t nHLT; Int_t HLT_Accept[3]; //[nHLT] Int_t HLT_Prescl[3]; //[nHLT] @@ -102,9 +103,15 @@ public : Double_t ProtCand_t[50]; //[nRecoProtCand] Double_t ProtCand_ThX[50]; //[nRecoProtCand] Double_t ProtCand_ThY[50]; //[nRecoProtCand] + Double_t ProtCand_ystar[50]; //[nRecoProtCand] Int_t ProtCand_rpid[50]; //[nRecoProtCand] Int_t ProtCand_arm[50]; //[nRecoProtCand] Int_t ProtCand_ismultirp[50]; //[nRecoProtCand] + Int_t ProtCand_trackpixshift1[50]; //[nRecoProtCand] + Double_t ProtCand_trackx1[50]; //[nRecoProtCand] + Double_t ProtCand_tracky1[50]; //[nRecoProtCand] + Double_t ProtCand_trackx2[50]; //[nRecoProtCand] + Double_t ProtCand_tracky2[50]; //[nRecoProtCand] UInt_t nExtraTracks; Int_t ExtraTrack_pair[2000]; //[nExtraTracks] Int_t ExtraTrack_purity[2000]; //[nExtraTracks] @@ -113,12 +120,16 @@ public : UInt_t ExtraTrack_ndof[2000]; //[nExtraTracks] Double_t ExtraTrack_px[2000]; //[nExtraTracks] Double_t ExtraTrack_py[2000]; //[nExtraTracks] + UInt_t nGenMuonCand; + Double_t GenMuonCand_pt[10]; //[nMuonCand] + Double_t GenMuonCand_eta[10]; //[nMuonCand] // List of branches TBranch *b_Run; //! TBranch *b_LumiSection; //! TBranch *b_BX; //! TBranch *b_EventNum; //! + TBranch *b_CrossingAngle; //! TBranch *b_nHLT; //! TBranch *b_HLT_Accept; //! TBranch *b_HLT_Prescl; //! @@ -195,9 +206,15 @@ public : TBranch *b_ProtCand_t; //! TBranch *b_ProtCand_ThX; //! TBranch *b_ProtCand_ThY; //! + TBranch *b_ProtCand_ystar; //! TBranch *b_ProtCand_rpid; //! TBranch *b_ProtCand_arm; //! TBranch *b_ProtCand_ismultirp; //! + TBranch *b_ProtCand_trackpixshift1; //! + TBranch *b_ProtCand_trackx1; //! + TBranch *b_ProtCand_tracky1; //! + TBranch *b_ProtCand_trackx2; //! + TBranch *b_ProtCand_tracky2; //! TBranch *b_nExtraTracks; //! TBranch *b_ExtraTrack_pair; //! TBranch *b_ExtraTrack_purity; //! @@ -206,6 +223,33 @@ public : TBranch *b_ExtraTrack_ndof; //! TBranch *b_ExtraTrack_px; //! TBranch *b_ExtraTrack_py; //! + TBranch *b_nGenMuonCand; //! + TBranch *b_GenMuonCand_pt; //! + TBranch *b_GenMuonCand_eta; //! + // Efficiency correction histograms + TH2F *hpixeffB45, *hpixeffC145, *hpixeffE45, *hpixeffF145; + TH2F *hpixeffB56, *hpixeffC156, *hpixeffE56, *hpixeffF156; + TH2F *hpixeff2017PreTS245, *hpixeff2017PostTS245; + TH2F *hpixeff2017PreTS256, *hpixeff2017PostTS256; + + TH2F *hstreffB45, *hstreffC145, *hstreffC245, *hstreffD45, *hstreffE45, *hstreffF145, *hstreffF245, *hstreffF345; + TH2F *hstreffB56, *hstreffC156, *hstreffC256, *hstreffD56, *hstreffE56, *hstreffF156, *hstreffF256, *hstreffF356; + TH2F *hstreff2017PreTS245, *hstreff2017PostTS245; + TH2F *hstreff2017PreTS256, *hstreff2017PostTS256; + + TH1F *hmultistreffB45, *hmultistreffC145, *hmultistreffC245, *hmultistreffD45, *hmultistreffE45, *hmultistreffF145, *hmultistreffF245, *hmultistreffF345; + TH1F *hmultistreffB56, *hmultistreffC156, *hmultistreffC256, *hmultistreffD56, *hmultistreffE56, *hmultistreffF156, *hmultistreffF256, *hmultistreffF356; + TH1F *hmultistreff2017PreTS245, *hmultistreff2017PostTS245; + TH1F *hmultistreff2017PreTS256, *hmultistreff2017PostTS256; + + // Systematics + TFile *fsyst; + TGraphErrors *grsyst45; + TGraphErrors *grsyst56; + + + TRandom *rnd; + Dimuons2017Macro(TTree *tree=0); virtual ~Dimuons2017Macro(); @@ -213,7 +257,9 @@ public : virtual Int_t GetEntry(Long64_t entry); virtual Long64_t LoadTree(Long64_t entry); virtual void Init(TTree *tree); - virtual void Loop(); + virtual void Loop(Int_t multi=0, Int_t mc=0, Int_t sb=1, Int_t yr=2017, Int_t nearfar=0); + virtual bool FiducalCuts(Float_t trackx220, Float_t tracky220, Int_t arm, Int_t run); + virtual Float_t MultiRPEffCorr(Float_t trackx210, Float_t tracky210, Float_t trackx220, Float_t tracky220, Int_t arm, Int_t run); virtual Bool_t Notify(); virtual void Show(Long64_t entry = -1); }; @@ -241,22 +287,107 @@ Dimuons2017Macro::Dimuons2017Macro(TTree *tree) : fChain(0) // The following code should be used if you want this class to access a chain // of trees. TChain * chain = new TChain("ggll_aod/ntp1",""); - // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_LPAIRmumuElastic_Summer17_Pt50_xangle130_divergence30.root/ggll_aod/ntp1"); - chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017B_merge.root/ggll_aod/ntp1"); - chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017C_merge_final.root/ggll_aod/ntp1"); - chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017D_merge.root/ggll_aod/ntp1"); - chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017E_merge.root/ggll_aod/ntp1"); - chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017F_merge.root/ggll_aod/ntp1"); - // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2018/ProtonReconstruction_DoubleMu2018B_merge.root/ggll_aod/ntp1"); - // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2018/ProtonReconstruction_DoubleMu2018C_merge.root/ggll_aod/ntp1"); - // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2018/ProtonReconstruction_DoubleMu2018D_merge.root/ggll_aod/ntp1"); + // 2017, Ultra-Legacy + /* + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017B_finalUL_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017C_finalUL_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017D_finalUL_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017E_finalUL_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017F_finalUL_merge.root/ggll_aod/ntp1"); + */ + + // 2017, re-MiniAOD test + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/2017/pps_2017B_dimuontestreminiaod/DoubleMuon/pps_2017B_dimuontestreminiaod/200507_105943/0000/pps_2017B_dimuontestreminiaod.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/2017/pps_2017C_dimuontestreminiaod/DoubleMuon/pps_2017C_dimuontestreminiaod/200507_110619/0000/pps_2017C_dimuontestreminiaod.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/2017/pps_2017D_dimuontestreminiaod_v2/DoubleMuon/pps_2017D_dimuontestreminiaod/200508_000704/0000/crab_pps_2017D_dimuontestreminiaod.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/2017/pps_2017E_dimuontestreminiaod/DoubleMuon/pps_2017E_dimuontestreminiaod/200507_110945/0000/crab_pps_2017E_dimuontestreminiaod.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/2017/pps_2017F_dimuontestreminiaod/DoubleMuon/pps_2017F_dimuontestreminiaod/200507_111241/0000/pps_2017F_dimuontestreminiaod.root/ggll_aod/ntp1"); + + // chain->Add("output_xangleall2017MC.root"); + // chain->Add("output_xangleall2017MC_noPUprotons.root"); + + // Final + // chain->Add("../test/output_xangleall2017MCpreTS2.root"); + // chain->Add("../test/output_xangleall2018MC.root"); + // chain->Add("../test/output_xangleall2017postTS2MC.root"); + + // Final for DPS + // chain->Add("output_MC_2017preTS2.root/ggll_aod/ntp1"); + // chain->Add("output_MC_2017preTS2.root/ggll_aod/ntp1"); + chain->Add("../reminiaodtests/output_MC_2017preTS2.root/ggll_aod/ntp1"); tree = chain; #endif // SINGLE_TREE } Init(tree); + + // Systematics + // fsyst = TFile::Open("/tmp/jjhollar/xi_uncertainty.root"); + fsyst = TFile::Open("reco_charactersitics_version1.root"); + + // Setup for efficiency corrections ("killing"), or just reading + rnd = new TRandom(); + rnd->SetSeed(123456); + + Float_t lumiB = 2.361; + Float_t lumiC1 = 5.3; + Float_t lumiC = 8.577; + Float_t lumiD = 4.075; + Float_t lumiE = 8.959; + Float_t lumiF1 = 1.7; + Float_t lumiF = 13.214; + + // Pixels - lumi-weighted averages for pre- and post-TS2 + TFile *fpixeff = TFile::Open("pixelEfficiencies_radiation.root"); + hpixeffB45 = (TH2F *)fpixeff->Get("Pixel/2017/2017B/h45_220_2017B_all_2D"); // 2.4fb + hpixeffB56 = (TH2F *)fpixeff->Get("Pixel/2017/2017B/h56_220_2017B_all_2D"); + hpixeffC145 = (TH2F *)fpixeff->Get("Pixel/2017/2017C1/h45_220_2017C1_all_2D"); // 5.3fb + hpixeffC156 = (TH2F *)fpixeff->Get("Pixel/2017/2017C1/h56_220_2017C1_all_2D"); + hpixeffE45 = (TH2F *)fpixeff->Get("Pixel/2017/2017E/h45_220_2017E_all_2D"); // 9fb + hpixeffE56 = (TH2F *)fpixeff->Get("Pixel/2017/2017E/h56_220_2017E_all_2D"); + hpixeffF145 = (TH2F *)fpixeff->Get("Pixel/2017/2017F1/h45_220_2017F1_all_2D"); // 1.7fb + hpixeffF156 = (TH2F *)fpixeff->Get("Pixel/2017/2017F1/h56_220_2017F1_all_2D"); + + // Strips - lumi-weighted averages for pre- and post-TS2 + TFile *fstripeff = TFile::Open("PreliminaryEfficiencies_October92019_1D2DMultiTrack.root"); + hstreffB45 = (TH2F *)fstripeff->Get("Strips/2017/2017B/h45_2017B_all_2D"); + hstreffC145 = (TH2F *)fstripeff->Get("Strips/2017/2017C1/h45_2017C1_all_2D"); + hstreffC245 = (TH2F *)fstripeff->Get("Strips/2017/2017C2/h45_2017C2_all_2D"); + hstreffD45 = (TH2F *)fstripeff->Get("Strips/2017/2017D/h45_2017D_all_2D"); + hstreffE45 = (TH2F *)fstripeff->Get("Strips/2017/2017E/h45_2017E_all_2D"); + hstreffF145 = (TH2F *)fstripeff->Get("Strips/2017/2017F1/h45_2017F1_all_2D"); + hstreffF245 = (TH2F *)fstripeff->Get("Strips/2017/2017F2/h45_2017F2_all_2D"); + hstreffF345 = (TH2F *)fstripeff->Get("Strips/2017/2017F3/h45_2017F3_all_2D"); + + hstreffB56 = (TH2F *)fstripeff->Get("Strips/2017/2017B/h56_2017B_all_2D"); + hstreffC156 = (TH2F *)fstripeff->Get("Strips/2017/2017C1/h56_2017C1_all_2D"); + hstreffC256 = (TH2F *)fstripeff->Get("Strips/2017/2017C2/h56_2017C2_all_2D"); + hstreffD56 = (TH2F *)fstripeff->Get("Strips/2017/2017D/h56_2017D_all_2D"); + hstreffE56 = (TH2F *)fstripeff->Get("Strips/2017/2017E/h56_2017E_all_2D"); + hstreffF156 = (TH2F *)fstripeff->Get("Strips/2017/2017F1/h56_2017F1_all_2D"); + hstreffF256 = (TH2F *)fstripeff->Get("Strips/2017/2017F2/h56_2017F2_all_2D"); + hstreffF356 = (TH2F *)fstripeff->Get("Strips/2017/2017F3/h56_2017F3_all_2D"); + + // Multi-track for strips + hmultistreffB45 = (TH1F *)fstripeff->Get("Strips/2017/2017B/h45multitrackeff_2017B_avg_RP3"); + hmultistreffC145 = (TH1F *)fstripeff->Get("Strips/2017/2017C1/h45multitrackeff_2017C1_avg_RP3"); + hmultistreffC245 = (TH1F *)fstripeff->Get("Strips/2017/2017C2/h45multitrackeff_2017C2_avg_RP3"); + hmultistreffD45 = (TH1F *)fstripeff->Get("Strips/2017/2017D/h45multitrackeff_2017D_avg_RP3"); + hmultistreffE45 = (TH1F *)fstripeff->Get("Strips/2017/2017E/h45multitrackeff_2017E_avg_RP3"); + hmultistreffF145 = (TH1F *)fstripeff->Get("Strips/2017/2017F1/h45multitrackeff_2017F1_avg_RP3"); + hmultistreffF245 = (TH1F *)fstripeff->Get("Strips/2017/2017F2/h45multitrackeff_2017F2_avg_RP3"); + hmultistreffF345 = (TH1F *)fstripeff->Get("Strips/2017/2017F3/h45multitrackeff_2017F3_avg_RP3"); + + hmultistreffB56 = (TH1F *)fstripeff->Get("Strips/2017/2017B/h56multitrackeff_2017B_avg_RP103"); + hmultistreffC156 = (TH1F *)fstripeff->Get("Strips/2017/2017C1/h56multitrackeff_2017C1_avg_RP103"); + hmultistreffC256 = (TH1F *)fstripeff->Get("Strips/2017/2017C2/h56multitrackeff_2017C2_avg_RP103"); + hmultistreffD56 = (TH1F *)fstripeff->Get("Strips/2017/2017D/h56multitrackeff_2017D_avg_RP103"); + hmultistreffE56 = (TH1F *)fstripeff->Get("Strips/2017/2017E/h56multitrackeff_2017E_avg_RP103"); + hmultistreffF156 = (TH1F *)fstripeff->Get("Strips/2017/2017F1/h56multitrackeff_2017F1_avg_RP103"); + hmultistreffF256 = (TH1F *)fstripeff->Get("Strips/2017/2017F2/h56multitrackeff_2017F2_avg_RP103"); + hmultistreffF356 = (TH1F *)fstripeff->Get("Strips/2017/2017F3/h56multitrackeff_2017F3_avg_RP103"); } Dimuons2017Macro::~Dimuons2017Macro() @@ -306,6 +437,7 @@ void Dimuons2017Macro::Init(TTree *tree) fChain->SetBranchAddress("LumiSection", &LumiSection, &b_LumiSection); fChain->SetBranchAddress("BX", &BX, &b_BX); fChain->SetBranchAddress("EventNum", &EventNum, &b_EventNum); + fChain->SetBranchAddress("CrossingAngle", &CrossingAngle, &b_CrossingAngle); fChain->SetBranchAddress("nHLT", &nHLT, &b_nHLT); fChain->SetBranchAddress("HLT_Accept", HLT_Accept, &b_HLT_Accept); fChain->SetBranchAddress("HLT_Prescl", HLT_Prescl, &b_HLT_Prescl); @@ -382,9 +514,15 @@ void Dimuons2017Macro::Init(TTree *tree) fChain->SetBranchAddress("ProtCand_t", ProtCand_t, &b_ProtCand_t); fChain->SetBranchAddress("ProtCand_ThX", ProtCand_ThX, &b_ProtCand_ThX); fChain->SetBranchAddress("ProtCand_ThY", ProtCand_ThY, &b_ProtCand_ThY); + fChain->SetBranchAddress("ProtCand_ystar", ProtCand_ystar, &b_ProtCand_ystar); fChain->SetBranchAddress("ProtCand_rpid", ProtCand_rpid, &b_ProtCand_rpid); fChain->SetBranchAddress("ProtCand_arm", ProtCand_arm, &b_ProtCand_arm); fChain->SetBranchAddress("ProtCand_ismultirp", ProtCand_ismultirp, &b_ProtCand_ismultirp); + fChain->SetBranchAddress("ProtCand_trackpixshift1", ProtCand_trackpixshift1, &b_ProtCand_trackpixshift1); + fChain->SetBranchAddress("ProtCand_trackx1", ProtCand_trackx1, &b_ProtCand_trackx1); + fChain->SetBranchAddress("ProtCand_tracky1", ProtCand_tracky1, &b_ProtCand_tracky1); + fChain->SetBranchAddress("ProtCand_trackx2", ProtCand_trackx2, &b_ProtCand_trackx2); + fChain->SetBranchAddress("ProtCand_tracky2", ProtCand_tracky2, &b_ProtCand_tracky2); fChain->SetBranchAddress("nExtraTracks", &nExtraTracks, &b_nExtraTracks); fChain->SetBranchAddress("ExtraTrack_pair", ExtraTrack_pair, &b_ExtraTrack_pair); fChain->SetBranchAddress("ExtraTrack_purity", ExtraTrack_purity, &b_ExtraTrack_purity); @@ -393,6 +531,10 @@ void Dimuons2017Macro::Init(TTree *tree) fChain->SetBranchAddress("ExtraTrack_ndof", ExtraTrack_ndof, &b_ExtraTrack_ndof); fChain->SetBranchAddress("ExtraTrack_px", ExtraTrack_px, &b_ExtraTrack_px); fChain->SetBranchAddress("ExtraTrack_py", ExtraTrack_py, &b_ExtraTrack_py); + fChain->SetBranchAddress("nGenMuonCand", &nGenMuonCand, &b_nGenMuonCand); + fChain->SetBranchAddress("GenMuonCand_pt", GenMuonCand_pt, &b_GenMuonCand_pt); + fChain->SetBranchAddress("GenMuonCand_eta", GenMuonCand_eta, &b_GenMuonCand_eta); + Notify(); } diff --git a/GammaGammaLeptonLepton/macros/Dimuons2018Macro.C b/GammaGammaLeptonLepton/macros/Dimuons2018Macro.C new file mode 100644 index 0000000..bb5554f --- /dev/null +++ b/GammaGammaLeptonLepton/macros/Dimuons2018Macro.C @@ -0,0 +1,930 @@ +#define Dimuons2018Macro_cxx +#include "Dimuons2018Macro.h" +#include +#include +#include + +bool Dimuons2018Macro::FiducalCuts(Float_t trackx210, Float_t tracky210, Float_t trackx220, Float_t tracky220, Int_t arm, Int_t run) +{ + float pixelX0_rotated = 0; + float pixelY0_rotated = 0; + float thex220 = 0.0; + float they220 = 0.0; + float thex210 = 0.0; + float they210 = 0.0; + + + float xmin_45_210, xmin_45_220, ymin_45_210, ymin_45_220, + xmax_45_210, xmax_45_220, ymax_45_210, ymax_45_220, + xmin_56_210, xmin_56_220, ymin_56_210, ymin_56_220, + xmax_56_210, xmax_56_220, ymax_56_210, ymax_56_220; + + if((run >= 315252) && (run <= 316995)) + { + // 2018A + xmin_45_210 = 2.850; xmax_45_210 = 17.927; ymin_45_210 = -11.598; ymax_45_210 = 3.698; + xmin_45_220 = 2.421; xmax_45_220 = 24.620; ymin_45_220 = -10.898; ymax_45_220 = 4.398; + xmin_56_210 = 3.275; xmax_56_210 = 18.498; ymin_56_210 = -11.298; ymax_56_210 = 3.298; + xmin_56_220 = 2.421; xmax_56_220 = 20.045; ymin_56_220 = -10.398; ymax_56_220 = 5.098; + } + if((run >= 316998) && (run <= 317696)) + { + // 2018B1 + xmin_45_210 = 2.850; xmax_45_210 = 17.927; ymin_45_210 = -11.598; ymax_45_210 = 3.698; + xmin_45_220 = 2.421; xmax_45_220 = 24.620; ymin_45_220 = -10.898; ymax_45_220 = 4.198; + xmin_56_210 = 3.275; xmax_56_210 = 18.070; ymin_56_210 = -11.198; ymax_56_210 = 4.098; + xmin_56_220 = 2.564; xmax_56_220 = 20.045; ymin_56_220 = -10.398; ymax_56_220 = 5.098; + } + if((run >= 318622) && (run <= 319312)) + { + // 2018B2 + xmin_45_210 = 2.564; xmax_45_210 = 17.640; ymin_45_210 = -11.598; ymax_45_210 = 4.198; + xmin_45_220 = 2.140; xmax_45_220 = 24.479; ymin_45_220 = -11.398; ymax_45_220 = 3.798; + xmin_56_210 = 3.275; xmax_56_210 = 17.931; ymin_56_210 = -10.498; ymax_56_210 = 4.098; + xmin_56_220 = 2.279; xmax_56_220 = 24.760; ymin_56_220 = -10.598; ymax_56_220 = 4.498; + } + if((run >= 319313) && (run <= 320393)) + { + // 2018C + xmin_45_210 = 2.564; xmax_45_210 = 17.930; ymin_45_210 = -11.098; ymax_45_210 = 4.198; + xmin_45_220 = 2.421; xmax_45_220 = 24.620; ymin_45_220 = -11.398; ymax_45_220 = 3.698; + xmin_56_210 = 3.275; xmax_56_210 = 17.931; ymin_56_210 = -10.498; ymax_56_210 = 4.698; + xmin_56_220 = 2.279; xmax_56_220 = 24.760; ymin_56_220 = -10.598; ymax_56_220 = 4.398; + } + if((run >= 320394) && (run <= 322633)) + { + // 2018D1 + xmin_45_210 = 2.850; xmax_45_210 = 17.931; ymin_45_210 = -11.098; ymax_45_210 = 4.098; + xmin_45_220 = 2.421; xmax_45_220 = 24.620; ymin_45_220 = -11.398; ymax_45_220 = 3.698; + xmin_56_210 = 3.275; xmax_56_210 = 17.931; ymin_56_210 = -10.498; ymax_56_210 = 4.698; + xmin_56_220 = 2.279; xmax_56_220 = 24.760; ymin_56_220 = -10.598; ymax_56_220 = 4.398; + } + if((run >= 323363) && (run <= 325273)) + { + // 2018D2 + xmin_45_210 = 2.850; xmax_45_210 = 17.931; ymin_45_210 = -10.598; ymax_45_210 = 4.498; + xmin_45_220 = 2.421; xmax_45_220 = 24.620; ymin_45_220 = -11.698; ymax_45_220 = 3.298; + xmin_56_210 = 3.275; xmax_56_210 = 17.931; ymin_56_210 = -9.998; ymax_56_210 = 4.698; + xmin_56_220 = 2.279; xmax_56_220 = 24.760; ymin_56_220 = -10.598; ymax_56_220 = 3.898; + } + + pixelX0_rotated = trackx210 * TMath::Cos((-8. / 180.) * TMath::Pi()) - + tracky210 * TMath::Sin((-8. / 180.) * TMath::Pi()); + pixelY0_rotated = trackx210 * TMath::Sin((-8. / 180.) * TMath::Pi()) + + tracky210 * TMath::Cos((-8. / 180.) * TMath::Pi()); + + thex210 = pixelX0_rotated; + they210 = pixelY0_rotated; + + thex220 = trackx220; + they220 = tracky220; + + bool pass = false; + + if(arm == 0) + { + if(((thex210 >= xmin_45_210) && (thex210 <= xmax_45_210)) && + ((they210 >= ymin_45_210) && (they210 <= ymax_45_210)) && + ((thex220 >= xmin_45_220) && (thex220 <= xmax_45_220)) && + ((they220 >= ymin_45_220) && (they220 <= ymax_45_220))) + { + pass = true; + } + } + if(arm == 1) + { + if(((thex210 >= xmin_56_210) && (thex210 <= xmax_56_210)) && + ((they210 >= ymin_56_210) && (they210 <= ymax_56_210)) && + ((thex220 >= xmin_56_220) && (thex220 <= xmax_56_220)) && + ((they220 >= ymin_56_220) && (they220 <= ymax_56_220))) + { + pass = true; + } + } + + if(pass == false) + { + std::cout << "\t\t\tIn pixel fiducial cuts: x, y, x, y = " << thex210 << ", " << they210 << ", " + << thex220 << ", " << they220 << std::endl; + if(arm == 0) + std::cout << "\t\t\t\tArm 45 Limits = " << xmin_45_210 << "-" << xmax_45_210 << ", " + << ymin_45_210 << "-" << ymax_45_210 << ", " + << xmin_45_220 << "-" << xmax_45_220 << ", " + << ymin_45_220 << "-" << ymax_45_220 << std::endl; + if(arm == 1) + std::cout << "\t\t\t\tArm 56 Limits = " << xmin_56_210 << "-" << xmax_56_210 << ", " + << ymin_56_210 << "-" << ymax_56_210 << ", " + << xmin_56_220 << "-" << xmax_56_220 << ", " + << ymin_56_220 << "-" << ymax_56_220 << std::endl; + + } + + + return pass; +} + +float Dimuons2018Macro::MultiRPEffCorr(Float_t trackx210, Float_t tracky210, Float_t trackx220, Float_t tracky220, Int_t arm, Int_t run) +{ + float effcorrpixrad210 = 1.0; + float effcorrpixrad220 = 1.0; + float effcorrmultitrk = 1.0; + + Int_t theera = 0; + + if((run >= 315252) && (run <= 316995)) + theera = 1; // 2018A + if((run >= 316998) && (run <= 317696)) + theera = 2; // 2018B1 + if((run >= 318622) && (run <= 319312)) + theera = 3; // 2018B2 + if((run >= 319313) && (run <= 320393)) + theera = 4; // 2018C + if((run >= 320394) && (run <= 322633)) + theera = 5; // 2018D1 + if((run >= 323363) && (run <= 325273)) + theera = 6; // 2018D2 + + // Rad damage + if(theera == 1) + { + if(arm == 0) + { + effcorrpixrad220 = hpixeffA45220->GetBinContent(hpixeffA45220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffA45210->GetBinContent(hpixeffA45210->FindBin(trackx210,tracky210)); + } + if(arm == 1) + { + effcorrpixrad220 = hpixeffA56220->GetBinContent(hpixeffA56220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffA56210->GetBinContent(hpixeffA56210->FindBin(trackx210,tracky210)); + } + } + if(theera == 2) + { + if(arm == 0) + { + effcorrpixrad220 = hpixeffB145220->GetBinContent(hpixeffB145220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffB145210->GetBinContent(hpixeffB145210->FindBin(trackx210,tracky210)); + } + if(arm == 1) + { + effcorrpixrad220 = hpixeffB156220->GetBinContent(hpixeffB156220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffB156210->GetBinContent(hpixeffB156210->FindBin(trackx210,tracky210)); + } + } + if(theera == 3) + { + if(arm == 0) + { + effcorrpixrad220 = hpixeffB245220->GetBinContent(hpixeffB245220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffB245210->GetBinContent(hpixeffB245210->FindBin(trackx210,tracky210)); + } + if(arm == 1) + { + effcorrpixrad220 = hpixeffB256220->GetBinContent(hpixeffB256220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffB256210->GetBinContent(hpixeffB256210->FindBin(trackx210,tracky210)); + } + } + if(theera == 4) + { + if(arm == 0) + { + effcorrpixrad220 = hpixeffC45220->GetBinContent(hpixeffC45220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffC45210->GetBinContent(hpixeffC45210->FindBin(trackx210,tracky210)); + } + if(arm == 1) + { + effcorrpixrad220 = hpixeffC56220->GetBinContent(hpixeffC56220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffC56210->GetBinContent(hpixeffC56210->FindBin(trackx210,tracky210)); + } + } + if(theera == 5) + { + if(arm == 0) + { + effcorrpixrad220 = hpixeffD145220->GetBinContent(hpixeffD145220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffD145210->GetBinContent(hpixeffD145210->FindBin(trackx210,tracky210)); + } + if(arm == 1) + { + effcorrpixrad220 = hpixeffD156220->GetBinContent(hpixeffD156220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffD156210->GetBinContent(hpixeffD156210->FindBin(trackx210,tracky210)); + } + } + if(theera == 6) + { + if(arm == 0) + { + effcorrpixrad220 = hpixeffD245220->GetBinContent(hpixeffD245220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffD245210->GetBinContent(hpixeffD245210->FindBin(trackx210,tracky210)); + } + if(arm == 1) + { + effcorrpixrad220 = hpixeffD256220->GetBinContent(hpixeffD256220->FindBin(trackx220,tracky220)); + effcorrpixrad210 = hpixeffD256210->GetBinContent(hpixeffD256210->FindBin(trackx210,tracky210)); + } + } + + std::cout << "Efficiencies:" << std::endl + << "\t x(210) = " << trackx210 << ", y(210) = " << tracky210 << ", x(220) = " << trackx220 << ", y(220) = " << tracky220 << std::endl + << "\tEra = " << theera << ", arm = " << arm << ", run = " << run << ", eff210 = " << effcorrpixrad210 << ", eff220 = " << effcorrpixrad220 << std::endl; + + float efftotal = (effcorrpixrad210 * effcorrpixrad220); + + return efftotal; +} + +void Dimuons2018Macro::Loop(Int_t multi, Int_t mc, Int_t sb, Int_t yr, Int_t nearfar) +{ +// In a ROOT session, you can do: +// root> .L Dimuons2018Macro.C +// root> Dimuons2018Macro t +// root> t.GetEntry(12); // Fill t data members with entry number 12 +// root> t.Show(); // Show values of entry 12 +// root> t.Show(16); // Read and show values of entry 16 +// root> t.Loop(); // Loop on all entries +// + +// This is the loop skeleton where: +// jentry is the global entry number in the chain +// ientry is the entry number in the current Tree +// Note that the argument to GetEntry must be: +// jentry for TChain::GetEntry +// ientry for TTree::GetEntry and TBranch::GetEntry +// +// To read only selected branches, Insert statements like: +// METHOD1: +// fChain->SetBranchStatus("*",0); // disable all branches +// fChain->SetBranchStatus("branchname",1); // activate branchname +// METHOD2: replace line +// fChain->GetEntry(jentry); //read all branches +//by b_branchname->GetEntry(ientry); //read only this branch + if (fChain == 0) return; + + TH1F *hacop = new TH1F("hacop","hacop",1000,0,0.01); + TH2F *hcorr45 = new TH2F("hcorr45","hcorr45",500,0,0.25,500,0,0.25); + TH2F *hcorr56 = new TH2F("hcorr56","hcorr56",500,0,0.25,500,0,0.25); + + TH2F *hcorrmult45 = new TH2F("hcorrmult45","hcorrmult45",500,0,0.25,500,0,0.25); + TH2F *hcorrmult56 = new TH2F("hcorrmult56","hcorrmult56",500,0,0.25,500,0,0.25); + + + TH1F *hres45 = new TH1F("hres45","hres45",300,-5,1); + TH1F *hres56 = new TH1F("hres56","hres56",300,-5,1); + TH1F *hressum = new TH1F("hressum","hressum",300,-5,1); + + TH1F *hbin145 = new TH1F("hbin145","hbin145",300,-5,1); + TH1F *hbin156 = new TH1F("hbin156","hbin156",300,-5,1); + TH1F *hbin1sum = new TH1F("hbin1sum","hbin1sum",300,-5,1); + TH1F *hbin245 = new TH1F("hbin245","hbin245",300,-5,1); + TH1F *hbin256 = new TH1F("hbin256","hbin256",300,-5,1); + TH1F *hbin2sum = new TH1F("hbin2sum","hbin2sum",300,-5,1); + TH1F *hbin345 = new TH1F("hbin345","hbin345",300,-5,1); + TH1F *hbin356 = new TH1F("hbin356","hbin356",300,-5,1); + TH1F *hbin3sum = new TH1F("hbin3sum","hbin3sum",300,-5,1); + TH1F *hbin445 = new TH1F("hbin445","hbin445",300,-5,1); + TH1F *hbin456 = new TH1F("hbin456","hbin456",300,-5,1); + TH1F *hbin4sum = new TH1F("hbin4sum","hbin4sum",300,-5,1); + + TH1F *hbin3mult45 = new TH1F("hbin3mult45","hbin3mult45",300,-5,1); + TH1F *hbin3mult56 = new TH1F("hbin3mult56","hbin3mult56",300,-5,1); + TH1F *hbin4mult45 = new TH1F("hbin4mult45","hbin4mult45",300,-5,1); + TH1F *hbin4mult56 = new TH1F("hbin4mult56","hbin4mult56",300,-5,1); + + + TH1F *hres45mult = new TH1F("hres45mult","hres45mult",300,-5,1); + TH1F *hres56mult = new TH1F("hres56mult","hres56mult",300,-5,1); + TH1F *hressummult = new TH1F("hressummult","hressummult",300,-5,1); + + TH1F *hres45multgenmu = new TH1F("hres45multgenmu","hres45multgenmu",300,-5,1); + TH1F *hres56multgenmu = new TH1F("hres56multgenmu","hres56multgenmu",300,-5,1); + TH1F *hressummultgenmu = new TH1F("hressummultgenmu","hressummultgenmu",300,-5,1); + + + TH1F *hn45220 = new TH1F("hn45220","hn45220",10,0,10); + TH1F *hn56220 = new TH1F("hn56220","hn56220",10,0,10); + TH1F *hn45mult = new TH1F("hn45mult","hn45mult",10,0,10); + TH1F *hn56mult = new TH1F("hn56mult","hn56mult",10,0,10); + + TH1F *hxi45mult = new TH1F("hxi45mult","hxi45mult",100,0,0.25); + TH1F *hxi56mult = new TH1F("hxi56mult","hxi56mult",100,0,0.25); + TH1F *hxangle45mult = new TH1F("hxangle45mult","hxangle45mult",50,120,170); + TH1F *hxangle56mult = new TH1F("hxangle56mult","hxangle56mult",50,120,170); + TH1F *hxi45single = new TH1F("hxi45single","hxi45single",100,0,0.25); + TH1F *hxi56single = new TH1F("hxi56single","hxi56single",100,0,0.25); + TH1F *hxangle45single = new TH1F("hxangle45single","hxangle45single",50,120,170); + TH1F *hxangle56single = new TH1F("hxangle56single","hxangle56single",50,120,170); + + TH1F *hmresmulti = new TH1F("hmresmulti","hmresmulti",500,-15,5); + TH1F *hmressingle = new TH1F("hmressingle","hmressingle",500,-15,5); + TH1F *hmresmixed = new TH1F("hmresmixed","hmresmixed",500,-15,5); + TH2F *hmcorrmulti = new TH2F("hmcorrmulti","hmcorrmulti",250,0,2500,250,0,2500); + TH2F *hmcorrmixed = new TH2F("hmcorrmixed","hmcorrmixed",250,0,2500,250,0,2500); + TH2F *hmcorrsingle = new TH2F("hmcorrsingle","hmcorrsingle",250,0,2500,250,0,2500); + TH1F *hmmumu = new TH1F("hmmumu","hmmumu",250,0,2500); + TH2F *hycorrmulti = new TH2F("hycorrmulti","hycorrmulti",250,-2.5,2.5,250,-2.5,2.5); + TH2F *hycorrsingle = new TH2F("hycorrsingle","hycorrsingle",250,-2.5,2.5,250,-2.5,2.5); + TH2F *hycorrmixed = new TH2F("hycorrmixed","hycorrmixed",250,-2.5,2.5,250,-2.5,2.5); + TH2F *hdmdysingle = new TH2F("hdmdysingle","hdmdysingle",1000,-500,500,200,-2,2); + + TH1F *hmresycutsingle = new TH1F("hmresycutsingle","hmresycutsingle",500,-15,5); + TH1F *hmresycutmulti = new TH1F("hmresycutmulti","hmresycutmulti",500,-15,5); + TH1F *hmresycutmixed = new TH1F("hmresycutmixed","hmresycutmixed",500,-15,5); + + TH1F *hpzmumumultmatch45 = new TH1F("hpzmumumultmatch45","hpzmumumultmatch45",500,-2000,2000); + TH1F *hpzmumusinglematch45 = new TH1F("hpzmumusinglematch45","hpzmumusinglematch45",500,-2000,2000); + TH1F *hpzmumumultmatch56 = new TH1F("hpzmumumultmatch56","hpzmumumultmatch56",500,-2000,2000); + TH1F *hpzmumusinglematch56 = new TH1F("hpzmumusinglematch56","hpzmumusinglematch56",500,-2000,2000); + TH1F *hpzmumumultantimatch45 = new TH1F("hpzmumumultantimatch45","hpzmumumultantimatch45",500,-2000,2000); + TH1F *hpzmumusingleantimatch45 = new TH1F("hpzmumusingleantimatch45","hpzmumusingleantimatch45",500,-2000,2000); + TH1F *hpzmumumultantimatch56 = new TH1F("hpzmumumultantimatch56","hpzmumumultantimatch56",500,-2000,2000); + TH1F *hpzmumusingleantimatch56 = new TH1F("hpzmumusingleantimatch56","hpzmumusingleantimatch56",500,-2000,2000); + + TH1F *hgenpzmumu = new TH1F("hgenpzmumu","hgenpzmumu",500,-2000,2000); + + TH2F *hxivst45 = new TH2F("hxivst45","hxivst45",500,0,0.25,100,0,5); + TH2F *hxivst56 = new TH2F("hxivst56","hxivst56",500,0,0.25,100,0,5); + + + // 0.02-0.05, 0.05-0.075, and 0.075-0.25 + + ofstream ofs("TextOutputSingleMultiCorr.txt"); + ofstream ofs2("TextOutputMultiRPwithFidEffAndYstar2018.txt"); + + ofs2 << "Run,LS,Event,Arm,xing angle,xi(p),xi(mumu),ximatch,t,theta*x,theta*y,y*,eff" << std::endl; + + Int_t nentries = fChain->GetEntries(); + + TLorentzVector mu1,mu2,mumu; + + Int_t usemultitracks = 0; + Int_t ismc = 1; + Int_t issideband = 0; + Int_t year = 2017; + Int_t usenear = 0; + + usemultitracks = multi; + ismc = mc; + issideband = sb; + year = yr; + usenear = nearfar; + + Int_t id45 = 23; + Int_t id56 = 123; + if(usenear == 1) + { + id45 = 3; + id56 = 103; + } + + Long64_t nbytes = 0, nb = 0; + for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; + // if (Cut(ientry) < 0) continue; + + if(jentry % 10000 == 0) + std::cout << "Entry " << jentry << "/" << nentries << std::endl; + + Float_t theacop = 1-fabs(Pair_dphi[0])/3.14159; + + if(Pair_mass[0]<110) + continue; + if(MuonCand_pt[0]<50 || MuonCand_pt[1]<50) + continue; + if(MuonCand_istight[0]!=1 || MuonCand_istight[1]!=1) + continue; + if(MuonCand_charge[0] == MuonCand_charge[1]) + continue; + if((1-fabs(Pair_dphi[0])/3.14159 > 0.009) && (issideband == 0)) + continue; + // if((1-fabs(Pair_dphi[0])/3.14159 <= 0.009) && (issideband == 1)) + if((theacop <= 0.009 || theacop > 0.1) && (issideband == 1)) // JH - testing narrower sideband + continue; + if((Pair_extratracks0p5mm[0] > 0) && (issideband == 0)) + continue; + if((Pair_extratracks0p5mm[0] < 5 || Pair_extratracks0p5mm[0] > 10) && (issideband == 1)) + continue; + + mu1.SetPtEtaPhiE(MuonCand_pt[0],MuonCand_eta[0],MuonCand_phi[0],MuonCand_e[0]); + mu2.SetPtEtaPhiE(MuonCand_pt[1],MuonCand_eta[1],MuonCand_phi[1],MuonCand_e[1]); + mumu = mu1+mu2; + + + hacop->Fill(1-fabs(Pair_dphi[0])/3.14159); + + Float_t mumuxisol1 = (1.0/13000.0)*((MuonCand_pt[0]*TMath::Exp(MuonCand_eta[0]) + MuonCand_pt[1]*TMath::Exp(MuonCand_eta[1]))); + Float_t mumuxisol2 = (1.0/13000.0)*((MuonCand_pt[0]*TMath::Exp(-1*MuonCand_eta[0]) + MuonCand_pt[1]*TMath::Exp(-1*MuonCand_eta[1]))); + + Float_t genmumuxisol1 = (1.0/13000.0)*((GenMuonCand_pt[0]*TMath::Exp(GenMuonCand_eta[0]) + GenMuonCand_pt[1]*TMath::Exp(GenMuonCand_eta[1]))); + Float_t genmumuxisol2 = (1.0/13000.0)*((GenMuonCand_pt[0]*TMath::Exp(-1*GenMuonCand_eta[0]) + GenMuonCand_pt[1]*TMath::Exp(-1*GenMuonCand_eta[1]))); + + + Float_t protxi45 = 0.0; + Float_t protxi56 = 0.0; + Float_t protxi45single = 0.0; + Float_t protxi56single = 0.0; + Float_t protxi45multi = 0.0; + Float_t protxi56multi = 0.0; + Float_t protx45multi210 = 0.0; + Float_t proty45multi210 = 0.0; + Float_t protx45multi220 = 0.0; + Float_t proty45multi220 = 0.0; + Float_t protx56multi210 = 0.0; + Float_t proty56multi210 = 0.0; + Float_t protx56multi220 = 0.0; + Float_t proty56multi220 = 0.0; + Float_t mumuxi45 = 0.0; + Float_t mumuxi56 = 0.0; + Float_t prott45 = 0.0; + Float_t prott56 = 0.0; + Float_t protthx45 = 0.0; + Float_t protthy45 = 0.0; + Float_t protthx56 = 0.0; + Float_t protthy56 = 0.0; + Float_t protystar45 = 0.0; + Float_t protystar56 = 0.0; + Int_t ntrk45 = 0; + Int_t ntrk56 = 0; + + // JH - do this to select events with only 1 pixel track! + Int_t ncountpixel45 = 0; + Int_t ncountpixel56 = 0; + Int_t ncountmulti45 = 0; + Int_t ncountmulti56 = 0; + + for(Int_t p = 0; p < nRecoProtCand; p++) + { + if(ProtCand_rpid[p] == id45 && ProtCand_ismultirp[p]==0) + ncountpixel45++; + if(ProtCand_rpid[p] == id56 && ProtCand_ismultirp[p]==0) + ncountpixel56++; + if(ProtCand_ismultirp[p]==1 && ProtCand_arm[p]==0) + ncountmulti45++; + if(ProtCand_ismultirp[p]==1 && ProtCand_arm[p]==1) + ncountmulti56++; + } + + hn45220->Fill(ncountpixel45); + hn56220->Fill(ncountpixel56); + hn45mult->Fill(ncountmulti45); + hn56mult->Fill(ncountmulti56); + + + for(Int_t p = 0; p < nRecoProtCand; p++) + { + if(ProtCand_rpid[p] == id45 && ProtCand_ismultirp[p]==0 && ProtCand_trackpixshift1[p] < 1 && ntrk45 < 1 && (ncountpixel45==1 || usemultitracks==1)) + { + protxi45 = ProtCand_xi[p]; + protxi45single = protxi45; + hcorr45->Fill(protxi45,mumuxisol1); + hres45->Fill(1 - (protxi45/mumuxisol1)); + hressum->Fill(1 - (protxi45/mumuxisol1)); + + if(mumuxisol1 >= 0.02 && mumuxisol1 < 0.03) + hbin145->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.03 && mumuxisol1 < 0.04) + hbin245->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.04 && mumuxisol1 < 0.06) + hbin345->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.06) + hbin445->Fill(1 - (protxi45/mumuxisol1)); + + if(fabs(1 - (protxi45/mumuxisol1)) < 0.25) + { + hxi45single->Fill(protxi45); + hpzmumusinglematch45->Fill(mumu.Pz()); + } + else + hpzmumusingleantimatch45->Fill(mumu.Pz()); + + std::cout << "Run, Lumi, Event = " << Run << ", " << LumiSection << ", " << EventNum << std::endl; + std::cout << "\t xi(RP=3) = " << protxi45 << std::endl; + + // ofs << Run << " " << LumiSection << " " << EventNum << " Single 23 " << protxi45 << " " << (1 - (protxi45/mumuxisol1)) << std::endl; + + ntrk45++; + } + if(ProtCand_rpid[p] == id56 && ProtCand_ismultirp[p]==0 && ProtCand_trackpixshift1[p] < 1 && ntrk56 < 1 && (ncountpixel56==1 || usemultitracks==1)) + { + protxi56 = ProtCand_xi[p]; + protxi56single = protxi56; + hcorr56->Fill(protxi56,mumuxisol2); + hres56->Fill(1 - (protxi56/mumuxisol2)); + hressum->Fill(1 - (protxi56/mumuxisol2)); + + if(mumuxisol2 >= 0.02 && mumuxisol2 < 0.03) + hbin156->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.03 && mumuxisol2 < 0.04) + hbin256->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.04 && mumuxisol2 < 0.06) + hbin356->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.06) + hbin456->Fill(1 - (protxi56/mumuxisol2)); + + if(fabs(1 - (protxi56/mumuxisol2)) < 0.25) + { + hxi56single->Fill(protxi56); + hpzmumusinglematch56->Fill(mumu.Pz()); + } + else + hpzmumusingleantimatch56->Fill(mumu.Pz()); + + std::cout << "Run, Lumi, Event = " << Run << " " << LumiSection << " " << EventNum << std::endl; + std::cout << "\t xi(RP=103) = " <Get("2018_postTS2/multi rp-0/g_xi_unc_vs_xi"); + grsyst45 = (TGraphErrors *)fsyst->Get("2018_postTS2/multi rp-0/xi/g_systematics_vs_xi"); + std::cout << "Getting syst. shift for proton with xi = " << protxi45 << std::endl; + float systshift = grsyst45->Eval(protxi45); + std::cout << "xi(orig) = " << protxi45 << " + shift of " << systshift << " (" << systshift/protxi45 << \ + "%)" << std::endl; + protxi45 = protxi45 - systshift; + + + + // Tracks for eff. correction + protx45multi220 = ProtCand_trackx1[p]; + proty45multi220 = ProtCand_tracky1[p]; + protx45multi210 = ProtCand_trackx2[p]; + proty45multi210 = ProtCand_tracky2[p]; + + // if((FiducalCuts(protx45multi210, proty45multi210, protx45multi220, proty45multi220, 0, Run) == true)) + if(1) + { + hres45mult->Fill(1 - (protxi45/mumuxisol1)); + hressummult->Fill(1 - (protxi45/mumuxisol1)); + hcorrmult45->Fill(protxi45,mumuxisol1); + + hressummultgenmu->Fill(1 - (protxi45/genmumuxisol1)); + hres45multgenmu->Fill(1 - (protxi45/genmumuxisol1)); + + if(mumuxisol1 >= 0.04 && mumuxisol1 < 0.06) + hbin3mult45->Fill(1 - (protxi45/mumuxisol1)); + if(mumuxisol1 >= 0.06) + hbin4mult45->Fill(1 - (protxi45/mumuxisol1)); + + std::cout << "Run, Lumi, Event = " << Run << ", " << LumiSection << ", " << EventNum << std::endl; + std::cout << "\t xi(multi arm=45) = " << protxi45 << std::endl; + + if(fabs(1 - (protxi45/mumuxisol1)) < 0.10 && (mumuxisol1 >= 0.04)) + { + hxi45mult->Fill(protxi45); + hxangle45mult->Fill(CrossingAngle); + hpzmumumultmatch45->Fill(mumu.Pz()); + hxivst45->Fill(protxi45,prott45); + + float efficiency = MultiRPEffCorr(protx45multi210, proty45multi210, protx45multi220, proty45multi220, 0, Run); + + ofs2 << Run << "," << LumiSection << "," << EventNum << ",45," << CrossingAngle << "," << protxi45 << "," << mumuxisol1 << "," + << 1 - (protxi45/mumuxisol1) << "," << prott45 + << ", " << protthx45 << ", " << protthy45 << ", " << ", " << protystar45 << ", " << efficiency + << std::endl; + + if((FiducalCuts(protx45multi210, proty45multi210, protx45multi220, proty45multi220, 0, Run) == false)) + std::cout << "\t\tFailed fiducial cuts: " << protx45multi210 << ", " << proty45multi210 << ", " + << protx45multi220 << ", " << proty45multi220 << std::endl; + } + else + hpzmumumultantimatch45->Fill(mumu.Pz()); + } + } + + if(ProtCand_arm[p] == 1 && ProtCand_trackpixshift1[p] < 1 && ProtCand_ismultirp[p] == 1 && (ncountmulti56==1 || usemultitracks==1)) + { + protxi56 = ProtCand_xi[p]; + prott56 = -1.0*ProtCand_t[p]; + protthx56 = ProtCand_ThX[p]; + protthy56 = ProtCand_ThY[p]; + protystar56 = ProtCand_ystar[p]; + protxi56multi = protxi56; + + // JH: shift up 8% + protxi56 = protxi56 - (0.08*protxi56); + // JH: shift up by Jan's systematics file - old version for DPS + // grsyst56 = (TGraphErrors *)fsyst->Get("2018_postTS2/multi rp-1/g_xi_unc_vs_xi"); + grsyst56 = (TGraphErrors *)fsyst->Get("2018_postTS2/multi rp-1/xi/g_systematics_vs_xi"); + float systshift = grsyst56->Eval(protxi56); + std::cout << "xi(orig) = " << protxi56 << " + shift of " << systshift << " (" << systshift/protxi56 << "%)" << std::endl; + protxi56 = protxi56 - systshift; + + + // Tracks for eff. correction + protx56multi220 = ProtCand_trackx1[p]; + proty56multi220 = ProtCand_tracky1[p]; + protx56multi210 = ProtCand_trackx2[p]; + proty56multi210 = ProtCand_tracky2[p]; + + // if((FiducalCuts(protx56multi210, proty56multi210, protx56multi220, proty56multi220, 1, Run) == true)) + if(1) + { + hres56mult->Fill(1 - (protxi56/mumuxisol2)); + hressummult->Fill(1 - (protxi56/mumuxisol2)); + hcorrmult56->Fill(protxi56,mumuxisol2); + + hressummultgenmu->Fill(1 - (protxi56/genmumuxisol2)); + hres56multgenmu->Fill(1 - (protxi56/genmumuxisol2)); + + + if(mumuxisol2 >= 0.04 && mumuxisol2 < 0.06) + hbin3mult56->Fill(1 - (protxi56/mumuxisol2)); + if(mumuxisol2 >= 0.06) + hbin4mult56->Fill(1 - (protxi56/mumuxisol2)); + + + std::cout << "Run, Lumi, Event = " << Run << ", " << LumiSection << ", " << EventNum << std::endl; + std::cout << "\t xi(multi arm=56) = " << protxi56 << std::endl; + + if((fabs(1 - (protxi56/mumuxisol2)) > -0.05) && (fabs(1 - (protxi56/mumuxisol2)) < 0.20) && (mumuxisol2 >= 0.04)) + { + hxi56mult->Fill(protxi56); + hxangle56mult->Fill(CrossingAngle); + hpzmumumultmatch56->Fill(mumu.Pz()); + hxivst56->Fill(protxi56,prott56); + + float efficiency = MultiRPEffCorr(protx56multi210, proty56multi210, protx56multi220, proty56multi220, 1, Run); + + ofs2 << Run << "," << LumiSection << "," << EventNum << ",56," << CrossingAngle << "," << protxi56 << "," << mumuxisol2 << "," + << 1 - (protxi56/mumuxisol2) << "," << prott56 + << ", " << protthx56 << ", " << protthy56 << ", " << protystar56 << ", " << efficiency + << std::endl; + + if((FiducalCuts(protx56multi210, proty56multi210, protx56multi220, proty56multi220, 1, Run) == false)) + std::cout << "\t\tFailed fiducial cuts: " << protx56multi210 << ", " << proty56multi210 << ", " + << protx56multi220 << ", " << proty56multi220 << std::endl; + + } + else + hpzmumumultantimatch56->Fill(mumu.Pz()); + } + } + } + + ofs << Run << " " << LumiSection << " " << EventNum + << " Single 3 " << protxi45single << " " << (1 - (protxi45single/mumuxisol1)) + << " Single 103 " << protxi56single << " " << (1 - (protxi56single/mumuxisol2)) + << " Multi 3 " << protxi45multi << " " << (1 - (protxi45multi/mumuxisol1)) + << " Multi 103 " << protxi56multi << " " << (1 - (protxi56multi/mumuxisol2)) << std::endl; + + Float_t mpp = 0.0; + Float_t ypp = 0.0; + Float_t mmumu = mumu.M(); + Float_t ymumu = mumu.Rapidity(); + + hmmumu->Fill(mmumu); + if(protxi45multi > 0 && protxi56multi > 0) + { + mpp = 13000.0 * TMath::Sqrt(protxi45multi*protxi56multi); + ypp = 0.5 * TMath::Log(protxi45multi/protxi56multi); + std::cout << "mpp(multi) = " << mpp << ", mmumu = " << mmumu << std::endl; + hmresmulti->Fill((1 - (mpp/mmumu))); + hmcorrmulti->Fill(mmumu,mpp); + hycorrmulti->Fill(ymumu,ypp); + if(fabs(ypp-ymumu) < 0.3) + { + hmresycutmulti->Fill((1 - (mpp/mmumu))); + if(fabs(1 - (mpp/mmumu)) < 0.5) + std::cout << "HEY!!! Look at multi-multi event " << Run << ":" << LumiSection << ":" << EventNum + << " with m(mumu) = " << mmumu << ", m(pp) = " << mpp + << ", y(mumu) = " << ymumu << ", y(pp) = " << ypp + << ", xi(45) = " << protxi45multi << ", xi(56) = " << protxi56multi << std::endl; + } + } + if(protxi45multi > 0 && protxi56single > 0) + { + mpp = 13000.0 * TMath::Sqrt(protxi45multi*protxi56single); + ypp =0.5 * TMath::Log(protxi45multi/protxi56single); + std::cout << "mpp(mixed 45multi 56single) = " << mpp << ", mmumu = " << mmumu << std::endl; + hmresmixed->Fill((1 - (mpp/mmumu))); + hmcorrmixed->Fill(mmumu,mpp); + hycorrmixed->Fill(ymumu,ypp); + if(fabs(ypp-ymumu) < 0.3) + { + hmresycutmixed->Fill((1 - (mpp/mmumu))); + if(fabs(1 - (mpp/mmumu)) < 0.5) + std::cout << "HEY!!! Look at multi-sinlge event " << Run << ":" << LumiSection << ":" << EventNum + << " with m(mumu) = " << mmumu << ", m(pp) = " << mpp + << ", y(mumu) = " << ymumu << ", y(pp) = " << ypp + << ", xi(45) = " << protxi45multi << ", xi(56) = " << protxi56single << std::endl; + } + } + if(protxi56multi > 0 && protxi45single > 0) + { + mpp = 13000.0 * TMath::Sqrt(protxi45single*protxi56multi); + ypp =0.5 * TMath::Log(protxi45single/protxi56multi); + std::cout << "mpp(mixed 45single 56multi) = " << mpp << ", mmumu = " << mmumu << std::endl; + hmresmixed->Fill((1 - (mpp/mmumu))); + hmcorrmixed->Fill(mmumu,mpp); + hycorrmixed->Fill(ymumu,ypp); + if(fabs(ypp-ymumu) < 0.3) + { + hmresycutmixed->Fill((1 - (mpp/mmumu))); + if(fabs(1 - (mpp/mmumu)) < 0.5) + std::cout << "HEY!!! Look at single-multi event " << Run << ":" << LumiSection << ":" << EventNum + << " with m(mumu) = " << mmumu << ", m(pp) = " << mpp + << ", y(mumu) = " << ymumu << ", y(pp) = " << ypp + << ", xi(45) = " << protxi45single << ", xi(56) = " << protxi56multi << std::endl; + } + } + if(protxi45single > 0 && protxi56single > 0) + { + mpp = 13000.0 * TMath::Sqrt(protxi45single*protxi56single); + ypp =0.5 * TMath::Log(protxi45single/protxi56single); + std::cout << "mpp(single) = " << mpp << ", mmumu = " << mmumu << std::endl; + std::cout << "ypp(single) = " << ypp << ", ymumu = " << ymumu << std::endl; + hmressingle->Fill((1 - (mpp/mmumu))); + hmcorrsingle->Fill(mmumu,mpp); + hycorrsingle->Fill(ymumu,ypp); + hdmdysingle->Fill(mpp-mmumu,ypp-ymumu); + if(fabs(ypp-ymumu) < 0.3) + { + hmresycutsingle->Fill((1 - (mpp/mmumu))); + if(fabs(1 - (mpp/mmumu)) < 0.5) + std::cout << "HEY!!! Look at single-single event " << Run << ":" << LumiSection << ":" << EventNum + << " with m(mumu) = " << mmumu << ", m(pp) = " << mpp + << ", y(mumu) = " << ymumu << ", y(pp) = " << ypp + << ", xi(45) = " << protxi45single << ", xi(56) = " << protxi56single << std::endl; + } + } + } + + ofs.close(); + ofs2.close(); + + // TFile *fx = new TFile("MoreDimuons2017BCDEFWithMultiLegacyFinalFromDB.root","RECREATE"); + // TFile *fx = new TFile("MoreDimuons2017BCDEFSingleTrackiNearLegacyFinalFromDB.root","RECREATE"); + // TFile *fx = new TFile("MoreDimuons2017BCDEFSingleTrackFarLegacyFinalFromDBWithMass.root","RECREATE"); + + // TFile *fx = new TFile("MoreDimuons2017BCDEFWithMultiTrackFarLegacyFinalFromDBWithMass.root","RECREATE"); + // TFile *fx = new TFile("MoreDimuons2017MCallanglesSingleTrackLegacyFinalFromDB.root","RECREATE"); + // TFile *fx = new TFile("MoreDimuons2017MCallanglesWithMultiLegacyFinalFromDBWithMass.root","RECREATE"); + + TFile *fx; + + if(issideband == 0) + { + if(usemultitracks == 1) + { + if(ismc == 0) + { + if(year == 2017) + fx = new TFile("MoreDimuons2017BCDEFWithMultiTrackFarLegacyFinalFromDBWithMassMoreBins.root","RECREATE"); + if(year == 2018) + { + if(usenear == 0){fx = new TFile("MoreDimuons2018BCDWithMultiTrackFarLegacyFinalFromDBWithMassMoreBins.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2018BCDWithMultiTrackNearLegacyFinalFromDBWithMassMoreBins.root","RECREATE");} + } + } + if(ismc == 1) + { + if(year == 2017) + fx = new TFile("MoreDimuons2017MCallanglesWithMultiLegacyFinalFromDBWithMassMoreBins.root","RECREATE"); + if(year == 2018) + fx = new TFile("MoreDimuons2018MCallanglesWithMultiLegacyFinalFromDBWithMassMoreBins.root","RECREATE"); + } + } + if(usemultitracks == 0) + { + if(ismc == 0) + { + if(year == 2017) + { + if(usenear == 0){fx = new TFile("MoreDimuons2017BCDEFSingleTrackPixelsLegacyFinalFromDBWithMass.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2017BCDEFSingleTrackStripsLegacyFinalFromDBWithMass.root","RECREATE");} + // fx = new TFile("MoreDimuons2017BCDEFSingleTrackStripsLegacyFinalFromDBWithMass.root","RECREATE"); + } + if(year == 2018) + { + if(usenear == 0){fx = new TFile("MoreDimuons2018BCDSingleTrackPixelsFarLegacyFinalFromDBWithMass.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2018BCDSingleTrackPixelsNearLegacyFinalFromDBWithMass.root","RECREATE");} + } + } + if(ismc == 1) + { + if(year == 2017) + fx = new TFile("MoreDimuons2017MCallanglesWithMultiLegacyFinalFromDBWithMass.root","RECREATE"); + if(year == 2018) + fx = new TFile("MoreDimuons2018MCallanglesWithMultiLegacyFinalFromDBWithMass.root","RECREATE"); + } + } + } + if(issideband == 1) + { + if(usemultitracks == 1) + if(ismc == 0) + { + if(year == 2017) + fx = new TFile("MoreDimuons2017BCDEFWithMultiTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracksMoreBins.root","RECREATE"); + if(year == 2018) + { + if(usenear == 0){fx = new TFile("MoreDimuons2018BCDWithMultiTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracksMoreBins.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2018BCDWithMultiTrackNearLegacyFinalFromDBWithMassAntiAcop1to5tracksMoreBins.root","RECREATE");} + } + } + if(usemultitracks == 0) + if(ismc == 0) + { + if(year == 2017) + { + if(usenear == 0){fx = new TFile("MoreDimuons2017BCDEFSingleTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracks.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2017BCDEFSingleTrackNearLegacyFinalFromDBWithMassAntiAcop1to5tracks.root","RECREATE");} + } + if(year == 2018) + { + if(usenear == 0){fx = new TFile("MoreDimuons2018BCDSingleTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracks.root","RECREATE");} + if(usenear == 1){fx = new TFile("MoreDimuons2018BCDSingleTrackNearLegacyFinalFromDBWithMassAntiAcop1to5tracks.root","RECREATE");} + } + } + } + + hacop->Write(); + hcorr45->Write(); + hres45->Write(); + hcorr56->Write(); + hres56->Write(); + hressum->Write(); + hres45mult->Write(); + hres56mult->Write(); + hressummult->Write(); + + hressummultgenmu->Write(); + hres45multgenmu->Write(); + hres56multgenmu->Write(); + + + hbin145->Write(); + hbin245->Write(); + hbin345->Write(); + hbin445->Write(); + + hbin156->Write(); + hbin256->Write(); + hbin356->Write(); + hbin456->Write(); + + hbin3mult45->Write(); + hbin3mult56->Write(); + hbin4mult45->Write(); + hbin4mult56->Write(); + + hn45220->Write(); + hn56220->Write(); + hn45mult->Write(); + hn56mult->Write(); + + hcorrmult45->Write(); + hcorrmult56->Write(); + + hxi45mult->Write(); + hxi56mult->Write(); + hxangle45mult->Write(); + hxangle56mult->Write(); + hxi45single->Write(); + hxi56single->Write(); + + hmresmulti->Write(); + hmresmixed->Write(); + hmressingle->Write(); + hmcorrsingle->Write(); + hmcorrmulti->Write(); + hmcorrmixed->Write(); + + hmmumu->Write(); + hycorrsingle->Write(); + hycorrmulti->Write(); + hycorrmixed->Write(); + hdmdysingle->Write(); + hmresycutmulti->Write(); + hmresycutmixed->Write(); + hmresycutsingle->Write(); + + hpzmumusinglematch45->Write(); + hpzmumusinglematch56->Write(); + hpzmumumultmatch45->Write(); + hpzmumumultmatch56->Write(); + hpzmumusingleantimatch45->Write(); + hpzmumusingleantimatch56->Write(); + hpzmumumultantimatch45->Write(); + hpzmumumultantimatch56->Write(); + + hxivst45->Write(); + hxivst56->Write(); + + fx->Write(); +} diff --git a/GammaGammaLeptonLepton/macros/Dimuons2018Macro.h b/GammaGammaLeptonLepton/macros/Dimuons2018Macro.h new file mode 100644 index 0000000..dfa80a9 --- /dev/null +++ b/GammaGammaLeptonLepton/macros/Dimuons2018Macro.h @@ -0,0 +1,529 @@ +////////////////////////////////////////////////////////// +// This class has been automatically generated on +// Wed Mar 13 14:47:30 2019 by ROOT version 6.12/07 +// from TChain ggll_aod/ntp1/ +////////////////////////////////////////////////////////// + +#ifndef Dimuons2018Macro_h +#define Dimuons2018Macro_h + +#include +#include +#include + +// Header file for the classes stored in the TTree if any. +#include "vector" + +class Dimuons2018Macro { +public : + TTree *fChain; //!pointer to the analyzed TTree or TChain + Int_t fCurrent; //!current Tree number in a TChain + +// Fixed size dimensions of array or collections stored in the TTree if any. + + // Declaration of leaf types + UInt_t Run; + UInt_t LumiSection; + UInt_t BX; + UInt_t EventNum; + Float_t CrossingAngle; + UInt_t nHLT; + Int_t HLT_Accept[3]; //[nHLT] + Int_t HLT_Prescl[3]; //[nHLT] + vector *HLT_Name; + UInt_t nMuonCand; + Double_t MuonCand_pt[10]; //[nMuonCand] + Double_t MuonCand_eta[10]; //[nMuonCand] + Double_t MuonCand_phi[10]; //[nMuonCand] + Double_t MuonCand_e[10]; //[nMuonCand] + Int_t MuonCand_charge[10]; //[nMuonCand] + Double_t MuonCand_vtxx[10]; //[nMuonCand] + Double_t MuonCand_vtxy[10]; //[nMuonCand] + Double_t MuonCand_vtxz[10]; //[nMuonCand] + Double_t MuonCand_dxy[10]; //[nMuonCand] + Int_t MuonCand_nstatseg[10]; //[nMuonCand] + Int_t MuonCand_ntrklayers[10]; //[nMuonCand] + Int_t MuonCand_npxlhits[10]; //[nMuonCand] + Int_t MuonCand_isglobal[10]; //[nMuonCand] + Int_t MuonCand_istracker[10]; //[nMuonCand] + Int_t MuonCand_isstandalone[10]; //[nMuonCand] + Int_t MuonCand_ispfmuon[10]; //[nMuonCand] + Int_t MuonCand_istight[10]; //[nMuonCand] + Int_t MuonCandTrack_nmuchits[10]; //[nMuonCand] + Double_t MuonCandTrack_chisq[10]; //[nMuonCand] + Double_t MuonCand_innerTrackPt[10]; //[nMuonCand] + Double_t MuonCand_innerTrackEta[10]; //[nMuonCand] + Double_t MuonCand_innerTrackPhi[10]; //[nMuonCand] + Double_t MuonCand_innerTrackVtxz[10]; //[nMuonCand] + UInt_t nPrimVertexCand; + Double_t PrimVertexCand_x[97]; //[nPrimVertexCand] + Double_t PrimVertexCand_y[97]; //[nPrimVertexCand] + Double_t PrimVertexCand_z[97]; //[nPrimVertexCand] + Double_t PrimVertexCand_chi2[97]; //[nPrimVertexCand] + UInt_t PrimVertexCand_ndof[97]; //[nPrimVertexCand] + UInt_t PrimVertexCand_tracks[97]; //[nPrimVertexCand] + UInt_t nPair; + Int_t Pair_lepton1[10]; //[nPair] + Int_t Pair_lepton2[10]; //[nPair] + Double_t Pair_mass[10]; //[nPair] + Double_t Pair_pt[10]; //[nPair] + Double_t Pair_eta[10]; //[nPair] + Double_t Pair_phi[10]; //[nPair] + Double_t Pair_dpt[10]; //[nPair] + Double_t Pair_dphi[10]; //[nPair] + Double_t Pair_3Dangle[10]; //[nPair] + UInt_t Pair_extratracks0p5mm[10]; //[nPair] + UInt_t Pair_extratracks1mm[10]; //[nPair] + UInt_t Pair_extratracks2mm[10]; //[nPair] + UInt_t Pair_extratracks3mm[10]; //[nPair] + UInt_t Pair_extratracks4mm[10]; //[nPair] + UInt_t Pair_extratracks5mm[10]; //[nPair] + UInt_t Pair_extratracks1cm[10]; //[nPair] + UInt_t Pair_extratracks2cm[10]; //[nPair] + UInt_t Pair_extratracks3cm[10]; //[nPair] + UInt_t Pair_extratracks4cm[10]; //[nPair] + UInt_t Pair_extratracks5cm[10]; //[nPair] + UInt_t Pair_extratracks10cm[10]; //[nPair] + Double_t KalmanVertexCand_x[10]; //[nPair] + Double_t KalmanVertexCand_y[10]; //[nPair] + Double_t KalmanVertexCand_z[10]; //[nPair] + UInt_t nLocalProtCand; + Double_t LocalProtCand_x[100]; //[nLocalProtCand] + Double_t LocalProtCand_y[100]; //[nLocalProtCand] + Double_t LocalProtCand_t[100]; //[nLocalProtCand] + Double_t LocalProtCand_xSigma[100]; //[nLocalProtCand] + Double_t LocalProtCand_ySigma[100]; //[nLocalProtCand] + Double_t LocalProtCand_tSigma[100]; //[nLocalProtCand] + Int_t LocalProtCand_arm[100]; //[nLocalProtCand] + Int_t LocalProtCand_station[100]; //[nLocalProtCand] + Int_t LocalProtCand_pot[100]; //[nLocalProtCand] + Int_t LocalProtCand_rpid[100]; //[nLocalProtCand] + UInt_t nRecoProtCand; + Double_t ProtCand_xi[50]; //[nRecoProtCand] + Double_t ProtCand_t[50]; //[nRecoProtCand] + Double_t ProtCand_ThX[50]; //[nRecoProtCand] + Double_t ProtCand_ThY[50]; //[nRecoProtCand] + Double_t ProtCand_ystar[50]; //[nRecoProtCand] + Int_t ProtCand_rpid[50]; //[nRecoProtCand] + Int_t ProtCand_arm[50]; //[nRecoProtCand] + Int_t ProtCand_ismultirp[50]; //[nRecoProtCand] + Int_t ProtCand_trackpixshift1[50]; //[nRecoProtCand] + Double_t ProtCand_trackx1[50]; //[nRecoProtCand] + Double_t ProtCand_tracky1[50]; //[nRecoProtCand] + Double_t ProtCand_trackx2[50]; //[nRecoProtCand] + Double_t ProtCand_tracky2[50]; //[nRecoProtCand] + UInt_t nExtraTracks; + Int_t ExtraTrack_pair[2000]; //[nExtraTracks] + Int_t ExtraTrack_purity[2000]; //[nExtraTracks] + UInt_t ExtraTrack_nhits[2000]; //[nExtraTracks] + Int_t ExtraTrack_charge[2000]; //[nExtraTracks] + UInt_t ExtraTrack_ndof[2000]; //[nExtraTracks] + Double_t ExtraTrack_px[2000]; //[nExtraTracks] + Double_t ExtraTrack_py[2000]; //[nExtraTracks] + UInt_t nGenMuonCand; + Double_t GenMuonCand_pt[10]; //[nMuonCand] + Double_t GenMuonCand_eta[10]; //[nMuonCand] + + // List of branches + TBranch *b_Run; //! + TBranch *b_LumiSection; //! + TBranch *b_BX; //! + TBranch *b_EventNum; //! + TBranch *b_CrossingAngle; //! + TBranch *b_nHLT; //! + TBranch *b_HLT_Accept; //! + TBranch *b_HLT_Prescl; //! + TBranch *b_HLT_Name; //! + TBranch *b_nMuonCand; //! + TBranch *b_MuonCand_pt; //! + TBranch *b_MuonCand_eta; //! + TBranch *b_MuonCand_phi; //! + TBranch *b_MuonCand_e; //! + TBranch *b_MuonCand_charge; //! + TBranch *b_MuonCand_vtxx; //! + TBranch *b_MuonCand_vtxy; //! + TBranch *b_MuonCand_vtxz; //! + TBranch *b_MuonCand_dxy; //! + TBranch *b_MuonCand_nstatseg; //! + TBranch *b_MuonCand_ntrklayers; //! + TBranch *b_MuonCand_npxlhits; //! + TBranch *b_MuonCand_isglobal; //! + TBranch *b_MuonCand_istracker; //! + TBranch *b_MuonCand_isstandalone; //! + TBranch *b_MuonCand_ispfmuon; //! + TBranch *b_MuonCand_istight; //! + TBranch *b_MuonCandTrack_nmuchits; //! + TBranch *b_MuonCandTrack_chisq; //! + TBranch *b_MuonCand_innerTrackPt; //! + TBranch *b_MuonCand_innerTrackEta; //! + TBranch *b_MuonCand_innerTrackPhi; //! + TBranch *b_MuonCand_innerTrackVtxz; //! + TBranch *b_nPrimVertexCand; //! + TBranch *b_PrimVertexCand_x; //! + TBranch *b_PrimVertexCand_y; //! + TBranch *b_PrimVertexCand_z; //! + TBranch *b_PrimVertexCand_chi2; //! + TBranch *b_PrimVertexCand_ndof; //! + TBranch *b_PrimVertexCand_tracks; //! + TBranch *b_nPair; //! + TBranch *b_Pair_lepton1; //! + TBranch *b_Pair_lepton2; //! + TBranch *b_Pair_mass; //! + TBranch *b_Pair_pt; //! + TBranch *b_Pair_eta; //! + TBranch *b_Pair_phi; //! + TBranch *b_Pair_dpt; //! + TBranch *b_Pair_dphi; //! + TBranch *b_Pair_3Dangle; //! + TBranch *b_Pair_extratracks0p5mm; //! + TBranch *b_Pair_extratracks1mm; //! + TBranch *b_Pair_extratracks2mm; //! + TBranch *b_Pair_extratracks3mm; //! + TBranch *b_Pair_extratracks4mm; //! + TBranch *b_Pair_extratracks5mm; //! + TBranch *b_Pair_extratracks1cm; //! + TBranch *b_Pair_extratracks2cm; //! + TBranch *b_Pair_extratracks3cm; //! + TBranch *b_Pair_extratracks4cm; //! + TBranch *b_Pair_extratracks5cm; //! + TBranch *b_Pair_extratracks10cm; //! + TBranch *b_KalmanVertexCand_x; //! + TBranch *b_KalmanVertexCand_y; //! + TBranch *b_KalmanVertexCand_z; //! + TBranch *b_nLocalProtCand; //! + TBranch *b_LocalProtCand_x; //! + TBranch *b_LocalProtCand_y; //! + TBranch *b_LocalProtCand_t; //! + TBranch *b_LocalProtCand_xSigma; //! + TBranch *b_LocalProtCand_ySigma; //! + TBranch *b_LocalProtCand_tSigma; //! + TBranch *b_LocalProtCand_arm; //! + TBranch *b_LocalProtCand_station; //! + TBranch *b_LocalProtCand_pot; //! + TBranch *b_LocalProtCand_rpid; //! + TBranch *b_nRecoProtCand; //! + TBranch *b_ProtCand_xi; //! + TBranch *b_ProtCand_t; //! + TBranch *b_ProtCand_ThX; //! + TBranch *b_ProtCand_ThY; //! + TBranch *b_ProtCand_ystar; //! + TBranch *b_ProtCand_rpid; //! + TBranch *b_ProtCand_arm; //! + TBranch *b_ProtCand_ismultirp; //! + TBranch *b_ProtCand_trackpixshift1; //! + TBranch *b_ProtCand_trackx1; //! + TBranch *b_ProtCand_tracky1; //! + TBranch *b_ProtCand_trackx2; //! + TBranch *b_ProtCand_tracky2; //! + TBranch *b_nExtraTracks; //! + TBranch *b_ExtraTrack_pair; //! + TBranch *b_ExtraTrack_purity; //! + TBranch *b_ExtraTrack_nhits; //! + TBranch *b_ExtraTrack_charge; //! + TBranch *b_ExtraTrack_ndof; //! + TBranch *b_ExtraTrack_px; //! + TBranch *b_ExtraTrack_py; //! + TBranch *b_nGenMuonCand; //! + TBranch *b_GenMuonCand_pt; //! + TBranch *b_GenMuonCand_eta; //! + + // Efficiency correction histograms + TH2F *hpixeffA45210, *hpixeffB145210, *hpixeffB245210, *hpixeffC45210, *hpixeffD145210, *hpixeffD245210; + TH2F *hpixeffA56210, *hpixeffB156210, *hpixeffB256210, *hpixeffC56210, *hpixeffD156210, *hpixeffD256210; + TH2F *hpixeffA45220, *hpixeffB145220, *hpixeffB245220, *hpixeffC45220, *hpixeffD145220, *hpixeffD245220; + TH2F *hpixeffA56220, *hpixeffB156220, *hpixeffB256220, *hpixeffC56220, *hpixeffD156220, *hpixeffD256220; + + // Systematics + TFile *fsyst; + TGraphErrors *grsyst45; + TGraphErrors *grsyst56; + + + Dimuons2018Macro(TTree *tree=0); + virtual ~Dimuons2018Macro(); + virtual Int_t Cut(Long64_t entry); + virtual Int_t GetEntry(Long64_t entry); + virtual Long64_t LoadTree(Long64_t entry); + virtual void Init(TTree *tree); + virtual void Loop(Int_t multi=0, Int_t mc=0, Int_t sb=1, Int_t yr=2017, Int_t nearfar=0); + virtual bool FiducalCuts(Float_t trackx210, Float_t tracky210, Float_t trackx220, Float_t tracky220, Int_t arm, Int_t run); + virtual Float_t MultiRPEffCorr(Float_t trackx210, Float_t tracky210, Float_t trackx220, Float_t tracky220, Int_t arm, Int_t run); + virtual Bool_t Notify(); + virtual void Show(Long64_t entry = -1); +}; + +#endif + +#ifdef Dimuons2018Macro_cxx +Dimuons2018Macro::Dimuons2018Macro(TTree *tree) : fChain(0) +{ +// if parameter tree is not specified (or zero), connect the file +// used to generate this class and read the Tree. + if (tree == 0) { + +#ifdef SINGLE_TREE + // The following code should be used if you want this class to access + // a single tree instead of a chain + TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017F_merge.root"); + if (!f || !f->IsOpen()) { + f = new TFile("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/2017/ProtonReconstruction_DoubleMu2017F_merge.root"); + } + f->GetObject("ggll_aod/ntp1",tree); + +#else // SINGLE_TREE + + // The following code should be used if you want this class to access a chain + // of trees. + TChain * chain = new TChain("ggll_aod/ntp1",""); + + // 2017, Ultra-Legacy + /* + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017B_finalUL_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017C_finalUL_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017D_finalUL_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017E_finalUL_merge.root/ggll_aod/ntp1"); + chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2017F_finalUL_merge.root/ggll_aod/ntp1"); + */ + + + // chain->Add("output_xangleall2017MC.root"); + // chain->Add("output_xangleall2017MC_noPUprotons.root"); + + // Final + // chain->Add("../test/output_xangleall2017MCpreTS2.root"); + // chain->Add("../test/output_xangleall2018MC.root"); + // chain->Add("../test/output_xangleall2017postTS2MC.root"); + + + // 2018, final legacy tests + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2018A_finalUL_merge.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2018B_finalUL_merge.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2018C_finalUL_merge.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2018D_finalUL_merge.root/ggll_aod/ntp1"); + // chain->Add("output_xangleall2018MC.root"); + + // 2018D, re-MiniAOD tests + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2018A_reMiniAODtestUL_merge.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2018B_reMiniAODtestUL_merge.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2018C_reMiniAODtestUL_merge.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2018Dpart1_reMiniAODtestUL_merge.root/ggll_aod/ntp1"); + // chain->Add("/eos/cms/store/group/phys_pps/ProtonRecoValidation/Dileptons/FinalUltraLegacy/ProtonReconstruction_DoubleMu2018Dpart2_reMiniAODtestUL_merge.root/ggll_aod/ntp1"); + + // final DPS MC + chain->Add("../reminiaodtests/output_MC_2018.root/ggll_aod/ntp1"); + + tree = chain; +#endif // SINGLE_TREE + + } + Init(tree); + + // Systematics + // Old version for DPS + // fsyst = TFile::Open("/tmp/jjhollar/xi_uncertainty.root"); + fsyst = TFile::Open("reco_charactersitics_version1.root"); + + TFile *fpixeff = TFile::Open("pixelEfficiencies_radiation.root"); + hpixeffA45210 = (TH2F *)fpixeff->Get("Pixel/2018/2018A/h45_210_2018A_all_2D"); + hpixeffB145210 = (TH2F *)fpixeff->Get("Pixel/2018/2018B1/h45_210_2018B1_all_2D"); + hpixeffB245210 = (TH2F *)fpixeff->Get("Pixel/2018/2018B2/h45_210_2018B2_all_2D"); + hpixeffC45210 = (TH2F *)fpixeff->Get("Pixel/2018/2018C/h45_210_2018C_all_2D"); + hpixeffD145210 = (TH2F *)fpixeff->Get("Pixel/2018/2018D1/h45_210_2018D1_all_2D"); + hpixeffD245210 = (TH2F *)fpixeff->Get("Pixel/2018/2018D2/h45_210_2018D2_all_2D"); + + hpixeffA56210 = (TH2F *)fpixeff->Get("Pixel/2018/2018A/h56_210_2018A_all_2D"); + hpixeffB156210 = (TH2F *)fpixeff->Get("Pixel/2018/2018B1/h56_210_2018B1_all_2D"); + hpixeffB256210 = (TH2F *)fpixeff->Get("Pixel/2018/2018B2/h56_210_2018B2_all_2D"); + hpixeffC56210 = (TH2F *)fpixeff->Get("Pixel/2018/2018C/h56_210_2018C_all_2D"); + hpixeffD156210 = (TH2F *)fpixeff->Get("Pixel/2018/2018D1/h56_210_2018D1_all_2D"); + hpixeffD256210 = (TH2F *)fpixeff->Get("Pixel/2018/2018D2/h56_210_2018D2_all_2D"); + + hpixeffA45220 = (TH2F *)fpixeff->Get("Pixel/2018/2018A/h45_220_2018A_all_2D"); + hpixeffB145220 = (TH2F *)fpixeff->Get("Pixel/2018/2018B1/h45_220_2018B1_all_2D"); + hpixeffB245220 = (TH2F *)fpixeff->Get("Pixel/2018/2018B2/h45_220_2018B2_all_2D"); + hpixeffC45220 = (TH2F *)fpixeff->Get("Pixel/2018/2018C/h45_220_2018C_all_2D"); + hpixeffD145220 = (TH2F *)fpixeff->Get("Pixel/2018/2018D1/h45_220_2018D1_all_2D"); + hpixeffD245220 = (TH2F *)fpixeff->Get("Pixel/2018/2018D2/h45_220_2018D2_all_2D"); + + hpixeffA56220 = (TH2F *)fpixeff->Get("Pixel/2018/2018A/h56_220_2018A_all_2D"); + hpixeffB156220 = (TH2F *)fpixeff->Get("Pixel/2018/2018B1/h56_220_2018B1_all_2D"); + hpixeffB256220 = (TH2F *)fpixeff->Get("Pixel/2018/2018B2/h56_220_2018B2_all_2D"); + hpixeffC56220 = (TH2F *)fpixeff->Get("Pixel/2018/2018C/h56_220_2018C_all_2D"); + hpixeffD156220 = (TH2F *)fpixeff->Get("Pixel/2018/2018D1/h56_220_2018D1_all_2D"); + hpixeffD256220 = (TH2F *)fpixeff->Get("Pixel/2018/2018D2/h56_220_2018D2_all_2D"); +} + +Dimuons2018Macro::~Dimuons2018Macro() +{ + if (!fChain) return; + delete fChain->GetCurrentFile(); +} + +Int_t Dimuons2018Macro::GetEntry(Long64_t entry) +{ +// Read contents of entry. + if (!fChain) return 0; + return fChain->GetEntry(entry); +} +Long64_t Dimuons2018Macro::LoadTree(Long64_t entry) +{ +// Set the environment to read one entry + if (!fChain) return -5; + Long64_t centry = fChain->LoadTree(entry); + if (centry < 0) return centry; + if (fChain->GetTreeNumber() != fCurrent) { + fCurrent = fChain->GetTreeNumber(); + Notify(); + } + return centry; +} + +void Dimuons2018Macro::Init(TTree *tree) +{ + // The Init() function is called when the selector needs to initialize + // a new tree or chain. Typically here the branch addresses and branch + // pointers of the tree will be set. + // It is normally not necessary to make changes to the generated + // code, but the routine can be extended by the user if needed. + // Init() will be called many times when running on PROOF + // (once per file to be processed). + + // Set object pointer + HLT_Name = 0; + // Set branch addresses and branch pointers + if (!tree) return; + fChain = tree; + fCurrent = -1; + fChain->SetMakeClass(1); + + fChain->SetBranchAddress("Run", &Run, &b_Run); + fChain->SetBranchAddress("LumiSection", &LumiSection, &b_LumiSection); + fChain->SetBranchAddress("BX", &BX, &b_BX); + fChain->SetBranchAddress("EventNum", &EventNum, &b_EventNum); + fChain->SetBranchAddress("CrossingAngle", &CrossingAngle, &b_CrossingAngle); + fChain->SetBranchAddress("nHLT", &nHLT, &b_nHLT); + fChain->SetBranchAddress("HLT_Accept", HLT_Accept, &b_HLT_Accept); + fChain->SetBranchAddress("HLT_Prescl", HLT_Prescl, &b_HLT_Prescl); + fChain->SetBranchAddress("HLT_Name", &HLT_Name, &b_HLT_Name); + fChain->SetBranchAddress("nMuonCand", &nMuonCand, &b_nMuonCand); + fChain->SetBranchAddress("MuonCand_pt", MuonCand_pt, &b_MuonCand_pt); + fChain->SetBranchAddress("MuonCand_eta", MuonCand_eta, &b_MuonCand_eta); + fChain->SetBranchAddress("MuonCand_phi", MuonCand_phi, &b_MuonCand_phi); + fChain->SetBranchAddress("MuonCand_e", MuonCand_e, &b_MuonCand_e); + fChain->SetBranchAddress("MuonCand_charge", MuonCand_charge, &b_MuonCand_charge); + fChain->SetBranchAddress("MuonCand_vtxx", MuonCand_vtxx, &b_MuonCand_vtxx); + fChain->SetBranchAddress("MuonCand_vtxy", MuonCand_vtxy, &b_MuonCand_vtxy); + fChain->SetBranchAddress("MuonCand_vtxz", MuonCand_vtxz, &b_MuonCand_vtxz); + fChain->SetBranchAddress("MuonCand_dxy", MuonCand_dxy, &b_MuonCand_dxy); + fChain->SetBranchAddress("MuonCand_nstatseg", MuonCand_nstatseg, &b_MuonCand_nstatseg); + fChain->SetBranchAddress("MuonCand_ntrklayers", MuonCand_ntrklayers, &b_MuonCand_ntrklayers); + fChain->SetBranchAddress("MuonCand_npxlhits", MuonCand_npxlhits, &b_MuonCand_npxlhits); + fChain->SetBranchAddress("MuonCand_isglobal", MuonCand_isglobal, &b_MuonCand_isglobal); + fChain->SetBranchAddress("MuonCand_istracker", MuonCand_istracker, &b_MuonCand_istracker); + fChain->SetBranchAddress("MuonCand_isstandalone", MuonCand_isstandalone, &b_MuonCand_isstandalone); + fChain->SetBranchAddress("MuonCand_ispfmuon", MuonCand_ispfmuon, &b_MuonCand_ispfmuon); + fChain->SetBranchAddress("MuonCand_istight", MuonCand_istight, &b_MuonCand_istight); + fChain->SetBranchAddress("MuonCandTrack_nmuchits", MuonCandTrack_nmuchits, &b_MuonCandTrack_nmuchits); + fChain->SetBranchAddress("MuonCandTrack_chisq", MuonCandTrack_chisq, &b_MuonCandTrack_chisq); + fChain->SetBranchAddress("MuonCand_innerTrackPt", MuonCand_innerTrackPt, &b_MuonCand_innerTrackPt); + fChain->SetBranchAddress("MuonCand_innerTrackEta", MuonCand_innerTrackEta, &b_MuonCand_innerTrackEta); + fChain->SetBranchAddress("MuonCand_innerTrackPhi", MuonCand_innerTrackPhi, &b_MuonCand_innerTrackPhi); + fChain->SetBranchAddress("MuonCand_innerTrackVtxz", MuonCand_innerTrackVtxz, &b_MuonCand_innerTrackVtxz); + fChain->SetBranchAddress("nPrimVertexCand", &nPrimVertexCand, &b_nPrimVertexCand); + fChain->SetBranchAddress("PrimVertexCand_x", PrimVertexCand_x, &b_PrimVertexCand_x); + fChain->SetBranchAddress("PrimVertexCand_y", PrimVertexCand_y, &b_PrimVertexCand_y); + fChain->SetBranchAddress("PrimVertexCand_z", PrimVertexCand_z, &b_PrimVertexCand_z); + fChain->SetBranchAddress("PrimVertexCand_chi2", PrimVertexCand_chi2, &b_PrimVertexCand_chi2); + fChain->SetBranchAddress("PrimVertexCand_ndof", PrimVertexCand_ndof, &b_PrimVertexCand_ndof); + fChain->SetBranchAddress("PrimVertexCand_tracks", PrimVertexCand_tracks, &b_PrimVertexCand_tracks); + fChain->SetBranchAddress("nPair", &nPair, &b_nPair); + fChain->SetBranchAddress("Pair_lepton1", Pair_lepton1, &b_Pair_lepton1); + fChain->SetBranchAddress("Pair_lepton2", Pair_lepton2, &b_Pair_lepton2); + fChain->SetBranchAddress("Pair_mass", Pair_mass, &b_Pair_mass); + fChain->SetBranchAddress("Pair_pt", Pair_pt, &b_Pair_pt); + fChain->SetBranchAddress("Pair_eta", Pair_eta, &b_Pair_eta); + fChain->SetBranchAddress("Pair_phi", Pair_phi, &b_Pair_phi); + fChain->SetBranchAddress("Pair_dpt", Pair_dpt, &b_Pair_dpt); + fChain->SetBranchAddress("Pair_dphi", Pair_dphi, &b_Pair_dphi); + fChain->SetBranchAddress("Pair_3Dangle", Pair_3Dangle, &b_Pair_3Dangle); + fChain->SetBranchAddress("Pair_extratracks0p5mm", Pair_extratracks0p5mm, &b_Pair_extratracks0p5mm); + fChain->SetBranchAddress("Pair_extratracks1mm", Pair_extratracks1mm, &b_Pair_extratracks1mm); + fChain->SetBranchAddress("Pair_extratracks2mm", Pair_extratracks2mm, &b_Pair_extratracks2mm); + fChain->SetBranchAddress("Pair_extratracks3mm", Pair_extratracks3mm, &b_Pair_extratracks3mm); + fChain->SetBranchAddress("Pair_extratracks4mm", Pair_extratracks4mm, &b_Pair_extratracks4mm); + fChain->SetBranchAddress("Pair_extratracks5mm", Pair_extratracks5mm, &b_Pair_extratracks5mm); + fChain->SetBranchAddress("Pair_extratracks1cm", Pair_extratracks1cm, &b_Pair_extratracks1cm); + fChain->SetBranchAddress("Pair_extratracks2cm", Pair_extratracks2cm, &b_Pair_extratracks2cm); + fChain->SetBranchAddress("Pair_extratracks3cm", Pair_extratracks3cm, &b_Pair_extratracks3cm); + fChain->SetBranchAddress("Pair_extratracks4cm", Pair_extratracks4cm, &b_Pair_extratracks4cm); + fChain->SetBranchAddress("Pair_extratracks5cm", Pair_extratracks5cm, &b_Pair_extratracks5cm); + fChain->SetBranchAddress("Pair_extratracks10cm", Pair_extratracks10cm, &b_Pair_extratracks10cm); + fChain->SetBranchAddress("KalmanVertexCand_x", KalmanVertexCand_x, &b_KalmanVertexCand_x); + fChain->SetBranchAddress("KalmanVertexCand_y", KalmanVertexCand_y, &b_KalmanVertexCand_y); + fChain->SetBranchAddress("KalmanVertexCand_z", KalmanVertexCand_z, &b_KalmanVertexCand_z); + fChain->SetBranchAddress("nLocalProtCand", &nLocalProtCand, &b_nLocalProtCand); + fChain->SetBranchAddress("LocalProtCand_x", LocalProtCand_x, &b_LocalProtCand_x); + fChain->SetBranchAddress("LocalProtCand_y", LocalProtCand_y, &b_LocalProtCand_y); + fChain->SetBranchAddress("LocalProtCand_t", LocalProtCand_t, &b_LocalProtCand_t); + fChain->SetBranchAddress("LocalProtCand_xSigma", LocalProtCand_xSigma, &b_LocalProtCand_xSigma); + fChain->SetBranchAddress("LocalProtCand_ySigma", LocalProtCand_ySigma, &b_LocalProtCand_ySigma); + fChain->SetBranchAddress("LocalProtCand_tSigma", LocalProtCand_tSigma, &b_LocalProtCand_tSigma); + fChain->SetBranchAddress("LocalProtCand_arm", LocalProtCand_arm, &b_LocalProtCand_arm); + fChain->SetBranchAddress("LocalProtCand_station", LocalProtCand_station, &b_LocalProtCand_station); + fChain->SetBranchAddress("LocalProtCand_pot", LocalProtCand_pot, &b_LocalProtCand_pot); + fChain->SetBranchAddress("LocalProtCand_rpid", LocalProtCand_rpid, &b_LocalProtCand_rpid); + fChain->SetBranchAddress("nRecoProtCand", &nRecoProtCand, &b_nRecoProtCand); + fChain->SetBranchAddress("ProtCand_xi", ProtCand_xi, &b_ProtCand_xi); + fChain->SetBranchAddress("ProtCand_t", ProtCand_t, &b_ProtCand_t); + fChain->SetBranchAddress("ProtCand_ThX", ProtCand_ThX, &b_ProtCand_ThX); + fChain->SetBranchAddress("ProtCand_ThY", ProtCand_ThY, &b_ProtCand_ThY); + fChain->SetBranchAddress("ProtCand_ystar", ProtCand_ystar, &b_ProtCand_ystar); + fChain->SetBranchAddress("ProtCand_rpid", ProtCand_rpid, &b_ProtCand_rpid); + fChain->SetBranchAddress("ProtCand_arm", ProtCand_arm, &b_ProtCand_arm); + fChain->SetBranchAddress("ProtCand_ismultirp", ProtCand_ismultirp, &b_ProtCand_ismultirp); + fChain->SetBranchAddress("ProtCand_trackpixshift1", ProtCand_trackpixshift1, &b_ProtCand_trackpixshift1); + fChain->SetBranchAddress("ProtCand_trackx1", ProtCand_trackx1, &b_ProtCand_trackx1); + fChain->SetBranchAddress("ProtCand_tracky1", ProtCand_tracky1, &b_ProtCand_tracky1); + fChain->SetBranchAddress("ProtCand_trackx2", ProtCand_trackx2, &b_ProtCand_trackx2); + fChain->SetBranchAddress("ProtCand_tracky2", ProtCand_tracky2, &b_ProtCand_tracky2); + fChain->SetBranchAddress("nExtraTracks", &nExtraTracks, &b_nExtraTracks); + fChain->SetBranchAddress("ExtraTrack_pair", ExtraTrack_pair, &b_ExtraTrack_pair); + fChain->SetBranchAddress("ExtraTrack_purity", ExtraTrack_purity, &b_ExtraTrack_purity); + fChain->SetBranchAddress("ExtraTrack_nhits", ExtraTrack_nhits, &b_ExtraTrack_nhits); + fChain->SetBranchAddress("ExtraTrack_charge", ExtraTrack_charge, &b_ExtraTrack_charge); + fChain->SetBranchAddress("ExtraTrack_ndof", ExtraTrack_ndof, &b_ExtraTrack_ndof); + fChain->SetBranchAddress("ExtraTrack_px", ExtraTrack_px, &b_ExtraTrack_px); + fChain->SetBranchAddress("ExtraTrack_py", ExtraTrack_py, &b_ExtraTrack_py); + fChain->SetBranchAddress("nGenMuonCand", &nGenMuonCand, &b_nGenMuonCand); + fChain->SetBranchAddress("GenMuonCand_pt", GenMuonCand_pt, &b_GenMuonCand_pt); + fChain->SetBranchAddress("GenMuonCand_eta", GenMuonCand_eta, &b_GenMuonCand_eta); + + Notify(); +} + +Bool_t Dimuons2018Macro::Notify() +{ + // The Notify() function is called when a new file is opened. This + // can be either for a new TTree in a TChain or when when a new TTree + // is started when using PROOF. It is normally not necessary to make changes + // to the generated code, but the routine can be extended by the + // user if needed. The return value is currently not used. + + return kTRUE; +} + +void Dimuons2018Macro::Show(Long64_t entry) +{ +// Print contents of entry. +// If entry is not specified, print current entry + if (!fChain) return; + fChain->Show(entry); +} +Int_t Dimuons2018Macro::Cut(Long64_t entry) +{ +// This function may be called from Loop. +// returns 1 if entry is accepted. +// returns -1 otherwise. + return 1; +} +#endif // #ifdef Dimuons2018Macro_cxx diff --git a/GammaGammaLeptonLepton/macros/FitBinnedPlots.C b/GammaGammaLeptonLepton/macros/FitBinnedPlots.C new file mode 100644 index 0000000..e493e84 --- /dev/null +++ b/GammaGammaLeptonLepton/macros/FitBinnedPlots.C @@ -0,0 +1,620 @@ +#include "TPad.h" +#include "TLatex.h" +#include "TLine.h" +#include "TBox.h" +#include "TASImage.h" + +/* + * Template fit yields + * 0.02-0.03: 20.1(45) 0.2(56) + * 0.03-0.04: 21.8(45) 20.0(56) + * 0.04-0.06: 11.0(45) 12.5(56) + * > 0.06: 19.5(45) 10.7(56) + * > 0.04: 32.4(45) 25.3(56) + * > 0.02: 63.3(45) + * > 0.03: 40.5(56) + * > 0.04 mult: 10.4(45) 7.5(56) + * > 0.02,0.03: 99.7(45+56) + * > 0.04 mult: 17.9(45+56) + */ + +void FitBinnedPlots(TString hist = "hressum", Int_t rebinfact = 5, Int_t year = 2017, Int_t mode = 1, Int_t pot = 220, Float_t fitrange = 0.5, Int_t minimizer = 0) +{ + TFile *f0,*f1,*f2; + if(year == 2017) + { + if(pot == 220) + { + f0 = TFile::Open("MoreDimuons2017BCDEFSingleTrackPixelsLegacyFinalFromDBWithMass.root"); + f1 = TFile::Open("../macros/MoreDimuons2017BCDEFSingleTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracks.root"); + f2 = TFile::Open("MoreDimuons2017preTS2MCallanglesSingleTrack220LegacyFinalFromDBWithMass.root"); + } + if(pot == 210) + { + f0 = TFile::Open("MoreDimuons2017BCDEFSingleTrackStripsLegacyFinalFromDBWithMass.root"); + f1 = TFile::Open("MoreDimuons2017BCDEFSingleTrackNearLegacyFinalFromDBWithMassAntiAcop1to5tracks.root"); + f2 = TFile::Open("MoreDimuons2017MCapreTS2llanglesSingleTrack210LegacyFinalFromDBWithMass.root"); + } + } + if(year == 2018) + { + if(pot == 220) + { + f0 = TFile::Open("MoreDimuons2018ABCDSingleTrackPixelsFarLegacyFinalFromDBWithMass.root"); + f1 = TFile::Open("MoreDimuons2018ABCDSingleTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracks.root"); + f2 = TFile::Open("MoreDimuons2018MCallanglesWithMultiLegacyFinalFromDBWithMass.root"); + } + if(pot == 210) + { + f0 = TFile::Open("MoreDimuons2018ApartialBCDSingleTrackPixelsNearLegacyFinalFromDBWithMass.root"); + f1 = TFile::Open("MoreDimuons2018ApartialBCDSingleTrackNearLegacyFinalFromDBWithMassAntiAcop1to5tracks.root"); + f2 = TFile::Open("MoreDimuons2018MCallanglesSingleTrack210LegacyFinalFromDBWithMass.root"); + } + } + if(year == 20172018) + { + // f0 = TFile::Open("MoreDimuons2017BCDEF2018ApartialBCDWithMultiTrackFarLegacyFinalFromDBWithMassMoreBins.root"); + // f0 = TFile::Open("MoreDimuons2018ApartialBCDWithMultiTrackNearLegacyFinalFromDBWithMassMoreBins.root"); + // f1 = TFile::Open("MoreDimuons2017BCDEF2018BCDWithMultiTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracksMoreBins.root"); + if(pot == 220) + { + f0 = TFile::Open("MoreDimuons2017BCDEF2018ABCDSingleTrackPixelsFarLegacyFinalFromDBWithMass.root"); + f1 = TFile::Open("MoreDimuons2017BCDEF2018ABCDSingleTrackFarLegacyFinalFromDBWithMassAntiAcop1to5tracks.root"); + // f2 = TFile::Open("../../../../../CMSSW_10_6_0/src/DiffractiveForwardAnalysis/GammaGammaLeptonLepton/systematicsmacros/MoreDimuons20172018MCallanglesSingleTrack220LegacyFinalFromDBWithMass.root"); + // f2 = TFile::Open("MoreDimuons20172018MCallanglesWithMultiLegacyFinalFromDBWithMass.root"); + f2 = TFile::Open("MoreDimuons20172018MCallanglesWithMultiLegacyFinalFromDBWithMassMoreBins.root"); + } + if(pot == 210) + { + f0 = TFile::Open("MoreDimuons2017BCDEF2018ApartialBCDSingleTrack210LegacyFinalFromDBWithMass.root"); + f1 = TFile::Open("MoreDimuons2017BCDEF2018ApartialBCDSingleTrack210LegacyFinalFromDBWithMassAntiAcop1to5tracks.root"); + f2 = TFile::Open("MoreDimuons20172018MCallanglesSingleTrack210LegacyFinalFromDBWithMass.root"); + } + } + + // TH1F *hb145 = (TH1F *)f0->Get("hbin145"); + TH1F *hall; + TH1F *hbkg; + TH1F *hsig; + + Float_t siglo = -0.2; + Float_t sighi = 0.2; + Float_t bkglo = -1.5; + Float_t bkghi = -0.5; + Float_t fitmax = 25; + Float_t submax = 25; + + if(mode == 1) + { + hall = (TH1F *)f0->Get(hist); + hbkg = (TH1F *)f1->Get(hist); + hsig = (TH1F *)f2->Get(hist); + } + + TH1F *hsumall145 = (TH1F *)f0->Get("hbin145"); TH1F *hsumall245 = (TH1F *)f0->Get("hbin245"); + TH1F *hsumall345 = (TH1F *)f0->Get("hbin345"); TH1F *hsumall445 = (TH1F *)f0->Get("hbin445"); + TH1F *hsumall156 = (TH1F *)f0->Get("hbin156"); TH1F *hsumall256 = (TH1F *)f0->Get("hbin256"); + TH1F *hsumall356 = (TH1F *)f0->Get("hbin356"); TH1F *hsumall456 = (TH1F *)f0->Get("hbin456"); + + TH1F *hsumbkg145 = (TH1F *)f1->Get("hbin145"); TH1F *hsumbkg245 = (TH1F *)f1->Get("hbin245"); + TH1F *hsumbkg345 = (TH1F *)f1->Get("hbin345"); TH1F *hsumbkg445 = (TH1F *)f1->Get("hbin445"); + TH1F *hsumbkg156 = (TH1F *)f1->Get("hbin156"); TH1F *hsumbkg256 = (TH1F *)f1->Get("hbin256"); + TH1F *hsumbkg356 = (TH1F *)f1->Get("hbin356"); TH1F *hsumbkg456 = (TH1F *)f1->Get("hbin456"); + + TH1F *hsumsig145 = (TH1F *)f2->Get("hbin145"); TH1F *hsumsig245 = (TH1F *)f2->Get("hbin245"); + TH1F *hsumsig345 = (TH1F *)f2->Get("hbin345"); TH1F *hsumsig445 = (TH1F *)f2->Get("hbin445"); + TH1F *hsumsig156 = (TH1F *)f2->Get("hbin156"); TH1F *hsumsig256 = (TH1F *)f2->Get("hbin256"); + TH1F *hsumsig356 = (TH1F *)f2->Get("hbin356"); TH1F *hsumsig456 = (TH1F *)f2->Get("hbin456"); + + TH1F *hsummultall45 = (TH1F *)f0->Get("hbin3mult45"); + TH1F *hsummultbkg45 = (TH1F *)f1->Get("hbin3mult45"); + TH1F *hsummultsig45 = (TH1F *)f2->Get("hbin3mult45"); + TH1F *hsummultall56 = (TH1F *)f0->Get("hbin3mult56"); + TH1F *hsummultbkg56 = (TH1F *)f1->Get("hbin3mult56"); + TH1F *hsummultsig56 = (TH1F *)f2->Get("hbin3mult56"); + + TH1F *hsummultall345 = (TH1F *)f0->Get("hbin3mult45"); + TH1F *hsummultbkg345 = (TH1F *)f1->Get("hbin3mult45"); + TH1F *hsummultsig345 = (TH1F *)f2->Get("hbin3mult45"); + TH1F *hsummultall445 = (TH1F *)f0->Get("hbin4mult45"); + TH1F *hsummultbkg445 = (TH1F *)f1->Get("hbin4mult45"); + TH1F *hsummultsig445 = (TH1F *)f2->Get("hbin4mult45"); + + TH1F *hsummultall356 = (TH1F *)f0->Get("hbin3mult56"); + TH1F *hsummultbkg356 = (TH1F *)f1->Get("hbin3mult56"); + TH1F *hsummultsig356 = (TH1F *)f2->Get("hbin3mult56"); + TH1F *hsummultall456 = (TH1F *)f0->Get("hbin4mult56"); + TH1F *hsummultbkg456 = (TH1F *)f1->Get("hbin4mult56"); + TH1F *hsummultsig456 = (TH1F *)f2->Get("hbin4mult56"); + + + if(mode == 2) + { + hall = (TH1F *)hsumall145->Clone("hall"); hall->Add(hsumall245); hall->Add(hsumall345); hall->Add(hsumall445); + hbkg = (TH1F *)hsumbkg145->Clone("hbkg"); hbkg->Add(hsumbkg245); hbkg->Add(hsumbkg345); hbkg->Add(hsumbkg445); + hsig = (TH1F *)hsumsig145->Clone("hsig"); hsig->Add(hsumsig245); hsig->Add(hsumsig345); hsig->Add(hsumsig445); + fitmax = 50; submax = 35; + if(year == 20172018) + { + fitmax = 80; + submax = 60; + } + } + if(mode == 3) + { + hall = (TH1F *)hsumall256->Clone("hall"); hall->Add(hsumall356); hall->Add(hsumall456); + hbkg = (TH1F *)hsumbkg256->Clone("hbkg"); hbkg->Add(hsumbkg356); hbkg->Add(hsumbkg456); + hsig = (TH1F *)hsumsig256->Clone("hsig"); hsig->Add(hsumsig356); hsig->Add(hsumsig456); + fitmax = 50; submax = 35; + if(year == 20172018) + { + fitmax = 80; + submax = 60; + } + } + if(mode == 4) + { + if(pot == 220) + { + hall = (TH1F *)hsumall145->Clone("hall"); + hall->Add(hsumall245); hall->Add(hsumall345); hall->Add(hsumall445); hall->Add(hsumall256); hall->Add(hsumall356); hall->Add(hsumall456); + hbkg = (TH1F *)hsumbkg145->Clone("hbkg"); + hbkg->Add(hsumbkg245); hbkg->Add(hsumbkg345); hbkg->Add(hsumbkg445); hbkg->Add(hsumbkg256); hbkg->Add(hsumbkg356); hbkg->Add(hsumbkg456); + hsig = (TH1F *)hsumsig145->Clone("hsig"); + hsig->Add(hsumsig245); hsig->Add(hsumsig345); hsig->Add(hsumsig445); hsig->Add(hsumsig256); hsig->Add(hsumsig356); hsig->Add(hsumsig456); + fitmax = 50; submax = 30; + } + if(pot == 210) // Start from larger xi acceptance + { + hall = (TH1F *)hsumall245->Clone("hall"); + hall->Add(hsumall345); hall->Add(hsumall445); hall->Add(hsumall356); hall->Add(hsumall456); + hbkg = (TH1F *)hsumbkg245->Clone("hbkg"); + hbkg->Add(hsumbkg345); hbkg->Add(hsumbkg445); hbkg->Add(hsumbkg356); hbkg->Add(hsumbkg456); + hsig = (TH1F *)hsumsig245->Clone("hsig"); + hsig->Add(hsumsig345); hsig->Add(hsumsig445); hsig->Add(hsumsig356); hsig->Add(hsumsig456); + fitmax = 50; submax = 30; + } + if(year == 20172018) + { + fitmax = 80; + submax = 60; + } + } + if(mode == 5) + { + hall = (TH1F *)hsummultall345->Clone("hall"); hall->Add(hsummultall356); hall->Add(hsummultall445); hall->Add(hsummultall456); + hbkg = (TH1F *)hsummultbkg345->Clone("hbkg"); hbkg->Add(hsummultbkg356); hbkg->Add(hsummultbkg445); hbkg->Add(hsummultbkg456); + hsig = (TH1F *)hsummultsig345->Clone("hsig"); hsig->Add(hsummultsig356); hsig->Add(hsummultsig445); hsig->Add(hsummultsig456); + fitmax = 50; submax = 40; + if(year == 20172018) + { + fitmax = 80; + submax = 60; + } + + } + if(mode == 6) + { + hall = (TH1F *)hsumall345->Clone("hall"); hall->Add(hsumall445); + hbkg = (TH1F *)hsumbkg345->Clone("hbkg"); hbkg->Add(hsumbkg445); + hsig = (TH1F *)hsumsig345->Clone("hsig"); hsig->Add(hsumsig445); + } + if(mode == 7) + { + hall = (TH1F *)hsumall356->Clone("hall"); hall->Add(hsumall456); + hbkg = (TH1F *)hsumbkg356->Clone("hbkg"); hbkg->Add(hsumbkg456); + hsig = (TH1F *)hsumsig356->Clone("hsig"); hsig->Add(hsumsig456); + } + if(mode == 8) + { + hall = (TH1F *)hsummultall345->Clone("hall"); hall->Add(hsummultall445); + hbkg = (TH1F *)hsummultbkg345->Clone("hbkg"); hbkg->Add(hsummultbkg445); + hsig = (TH1F *)hsummultsig345->Clone("hsig"); hsig->Add(hsummultsig445); + + fitmax = 35; submax = 20; + if(year == 20172018) + { + fitmax = 80; + submax = 60; + } + } + if(mode == 9) + { + hall = (TH1F *)hsummultall356->Clone("hall"); hall->Add(hsummultall456); + hbkg = (TH1F *)hsummultbkg356->Clone("hbkg"); hbkg->Add(hsummultbkg456); + hsig = (TH1F *)hsummultsig356->Clone("hsig"); hsig->Add(hsummultsig456); + + fitmax = 35; submax = 20; + if(year == 20172018) + { + fitmax = 80; + submax = 60; + } + } + + if(year == 20172018) + { + fitmax = 50; + submax = 50; + } + + + TString thetitle = ""; + if(hist == "hbin145" || hist == "hbin156") + thetitle = "0.02 < #xi(#mu#mu) < 0.03"; + if(hist == "hbin245" || hist == "hbin256") + thetitle = "0.03 < #xi(#mu#mu) < 0.04"; + if(hist == "hbin345" || hist == "hbin356") + thetitle = "0.04 < #xi(#mu#mu) < 0.06"; + // thetitle = "#xi(#mu#mu) > 0.04"; + if(hist == "hbin445" || hist == "hbin456") + thetitle = "#xi(#mu#mu) > 0.06"; + if(mode == 2) + thetitle = "#xi(#mu#mu) > 0.02"; + if(mode == 3) + thetitle = "#xi(#mu#mu) > 0.03"; + if(mode == 4) + { + if(pot == 220) + thetitle = "#xi(#mu#mu) > 0.02, 0.03"; + if(pot == 210) + thetitle = "#xi(#mu#mu) > 0.03, 0.04"; + } + if(mode == 5) + thetitle = "#xi(#mu#mu) > 0.04"; + if(mode == 6 || mode == 7) + thetitle = "#xi(#mu#mu) > 0.04"; + if(mode == 8) + thetitle = "#xi(#mu#mu) > 0.04"; + if(mode == 9) + thetitle = "#xi(#mu#mu) > 0.04"; + if(hist == "hbin3mult45" || hist == "hbin3mult56") + thetitle = "0.04 < #xi(#mu#mu) < 0.06"; + if(hist == "hbin4mult45" || hist == "hbin4mult56") + thetitle = "#xi(#mu#mu) > 0.06"; + + if(year == 2017) + thetitle += ", 2017, L=36.9 fb^{-1}"; + if(year == 2018) + thetitle += ", 2018, L=52.2 fb^{-1}"; + if(year == 20172018) + thetitle += ", 2017+2018, L=89.1 fb^{-1}"; + + hall->Rebin(rebinfact); hbkg->Rebin(rebinfact); hsig->Rebin(rebinfact); + hall->GetXaxis()->SetRangeUser(-3,1); hbkg->GetXaxis()->SetRangeUser(-3,1); hsig->GetXaxis()->SetRangeUser(-3,1); + + hall->SetBinErrorOption(TH1::kPoisson); + // hbkg->SetBinErrorOption(TH1::kPoisson); + // hsig->SetBinErrorOption(TH1::kPoisson); + + TObjArray *mc = new TObjArray(2); // MC histograms are put in this array + mc->Add(hbkg); + mc->Add(hsig); + + TFractionFitter *fit = new TFractionFitter(hall,mc); + TVirtualFitter* vFit = (TVirtualFitter* )fit->GetFitter(); + fit->Constrain(0,0.0,1.0); + fit->Constrain(1,0.0,1.0); + fit->SetRangeX(hall->FindBin(-3),hall->FindBin(1)); + + // vFit->SetParameter(0,"bkg",0.0,1.0,0.0,1000.0); + // vFit->SetParameter(1,"sig",0.15,1.0,0.10,1000.0); + fit->Fit(); + + TH1* result = fit->GetPlot(); + result->SetLineStyle(3); + + double theFrac[2], err[2]; + fit->GetResult(0, theFrac[0], err[0]); + fit->GetResult(1, theFrac[1], err[1]); + + + if(1) + { + Float_t bkgshapenorm = hbkg->Integral(hbkg->FindBin(-5),hbkg->FindBin(-0.5)) + hbkg->Integral(hbkg->FindBin(0.5),hbkg->FindBin(1)); + Float_t datnorm = hall->Integral(hall->FindBin(-5),hall->FindBin(-0.5)) + hall->Integral(hall->FindBin(0.5),hall->FindBin(1)); + Float_t allnorm = hall->Integral(hall->FindBin(-5),hall->FindBin(1)); + hbkg->Scale(datnorm/bkgshapenorm); + Float_t scaledbkgnorm = hbkg->Integral(hbkg->FindBin(-5),hbkg->FindBin(1)); + Float_t signorm = allnorm - scaledbkgnorm; + hsig->Scale(signorm / hsig->Integral(hsig->FindBin(-5),hsig->FindBin(1))); + } + + // TCanvas *c2 = new TCanvas("c2","c2",800,800); + // c2->Divide(1,2); + TCanvas *c2 = new TCanvas("c2","c2",1200,400); + c2->Divide(2,1); + c2->cd(1); + hbkg->Scale(theFrac[0] * hall->GetSumOfWeights() / hbkg->GetSumOfWeights()); + hsig->Scale(theFrac[1] * hall->GetSumOfWeights() / hsig->GetSumOfWeights()); + + /* All floating */ + TH1F *hsplusb = (TH1F *)hsig->Clone("hsplusb"); + + hsplusb->Add(hbkg); // single-inel + double-inel + + hsplusb->SetMaximum(fitmax); + hsplusb->SetFillColor(0); + hsplusb->SetLineColor(4); + hsplusb->SetLineWidth(3); + hsplusb->SetLineColor(4); + // hsplusb->SetFillColor(4); + // hsplusb->SetTitle(thetitle); + hsplusb->SetTitle(0); + hsplusb->GetXaxis()->SetTitleSize(0.05); + hsplusb->GetYaxis()->SetTitleOffset(0.9); + hsplusb->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + hsplusb->SetYTitle("Events"); + hsplusb->Draw("hist"); + hbkg->SetLineColor(2); hbkg->SetMarkerStyle(0); + hbkg->SetFillColor(2); hbkg->Draw("histsame"); + hall->SetLineColor(1); hall->SetLineWidth(3); hall->SetMarkerColor(1); hall->SetMarkerStyle(20); hall->SetLineWidth(3); + + TH1F *hsplusberr = (TH1F *)hsplusb->Clone("hsplusberr"); + hsplusberr->SetFillColor(13); + hsplusberr->SetMarkerSize(0); + hsplusberr->Draw("E2same"); + // JH - PPD comments + hsplusb->Draw("histsame"); + hall->Draw("E0same"); + + hsplusberr->SetFillColor(13); + + + TLegend *le1 = new TLegend(0.15,0.3,0.65,0.85); + le1->AddEntry(hall,"Data"); + le1->AddEntry(hbkg,"Background shape"); + le1->AddEntry(hsplusberr,"Signal shape (pp#rightarrowp#mu#mup MC) + background"); + le1->SetLineWidth(0); + le1->Draw("same"); + + TLatex latex; + float l = gPad->GetLeftMargin(); + float t = gPad->GetTopMargin(); + latex.SetTextAlign(11); + latex.SetTextSize(0.6*t); + // TString cmsText = "#font[61]{CMS-TOTEM} #scale[0.76]{#font[52]{Preliminary}}"; + // latex.DrawLatexNDC(l+0.5,1-t-0.7*t,cmsText); + TString cmsText = "#font[61]{CMS-TOTEM}"; + latex.DrawLatexNDC(l+0.5,1-t-0.7*t,cmsText); + + TLatex latexb; + float lb = gPad->GetLeftMargin(); + float tb = gPad->GetTopMargin(); + latexb.SetTextAlign(11); + latexb.SetTextSize(0.6*t); + TString cmsTextb = "#font[42]{92.3 fb^{-1} (13 TeV)}"; + // latexb.DrawLatexNDC(lb+0.6,1-tb+0.2*tb,cmsTextb); + latexb.DrawLatexNDC(lb+0.5,1-tb+0.2*tb,cmsTextb); + + /* + TLatex latex; + l = gPad->GetLeftMargin(); + t = gPad->GetTopMargin(); + latex.SetTextAlign(11); + latex.SetTextSize(0.6*t); + TString cmsText = "#font[61]{CMS} #scale[0.76]{#font[52]{Preliminary 2017+2018, Sector 45 (#xi > 0.02) + Sector 56 (#xi > 0.03), 220m FAR}}"; + latex.DrawLatexNDC(l,1-t+0.2*t,cmsText); + */ + + c2->cd(2); + TH1F *hsub = (TH1F *)hall->Clone("hsub"); + hbkg->Sumw2(); + hsub->Add(hbkg,-1); + // hsub->Add(hsig,-1);hsub->Add(hbkg,-1); + hsub->SetBinErrorOption(TH1::kPoisson); + + hsig->GetXaxis()->SetRangeUser(-1,1); + // hsig->GetXaxis()->SetRangeUser(-3,1); + hsig->SetMinimum(-3); hsig->SetMaximum(hsub->GetMaximum()*2.0); //hsig->SetMaximum(submax); + hsig->SetStats(0); + hsig->GetXaxis()->SetTitleSize(0.05); + hsig->GetYaxis()->SetTitleOffset(0.9); + hsig->SetXTitle("1 - #xi(p)/#xi(#mu#mu)"); + hsig->SetFillColor(0); + hsig->SetLineColor(4); + hsig->SetLineWidth(3); + hsig->SetLineColor(4); + // hsig->SetFillColor(4); + hsig->SetTitle(0); + hsig->SetYTitle("Data - B"); + hsig->Draw("hist"); + + TH1F *hsigerr = (TH1F *)hsig->Clone("hsigerr"); + hsigerr->SetFillColor(13); + hsigerr->SetMarkerSize(0); + hsigerr->SetMarkerColor(0); + hsigerr->Draw("E2same"); + hsig->Draw("histsame"); + + // JH - testing Sept 8, 2020. ROOT doesn't handle asymmetric errors in the histogram subtraction. + // So test a "by hand" quadrature sum of the upper and lower errors instead. + // hsub->Draw("E0same"); + TGraphAsymmErrors *hsubasym = new TGraphAsymmErrors(hsub); + for(Int_t z = 0; z < hall->GetNbinsX(); z++) + { + float xup1 = hall->GetBinErrorUp(z+1); + float xup2 = hbkg->GetBinError(z+1); + float xupdiff = TMath::Sqrt(xup1*xup1 + xup2*xup2); + float xlo1 = hall->GetBinErrorLow(z+1); + float xlo2 = hbkg->GetBinError(z+1); + float xlodiff = TMath::Sqrt(xlo1*xlo1 + xlo2*xlo2); + hsubasym->SetPointEYhigh(z,xupdiff); + hsubasym->SetPointEYlow(z,xlodiff); + hsubasym->SetPointEXhigh(z,0); + hsubasym->SetPointEXlow(z,0); + } + hsubasym->SetMarkerStyle(20); + hsubasym->SetMarkerColor(0); + hsubasym->Draw("E0same"); + + Float_t nbkgpeak = hbkg->Integral(hbkg->FindBin(-0.15),hbkg->FindBin(0.15)); + + TLegend *le2 = new TLegend(0.15,0.3,0.45,0.85); + le2->AddEntry(hsub,"Background-subtracted data"); + le2->AddEntry(hsigerr,"Signal shape (pp#rightarrowp#mu#mup MC)"); + le2->SetLineWidth(0); + le2->Draw("same"); + + TLatex latex2; + float l2 = gPad->GetLeftMargin(); + float t2 = gPad->GetTopMargin(); + latex2.SetTextAlign(11); + latex2.SetTextSize(0.6*t); + // TString cmsText2 = "#font[61]{CMS-TOTEM} #scale[0.76]{#font[52]{Preliminary}}"; + TString cmsText2 = "#font[61]{CMS-TOTEM}"; + // latex2.DrawLatexNDC(l2+0.5,1-t2-0.7*t,cmsText2); + latex2.DrawLatexNDC(l2+0.5,1-t2-0.7*t,cmsText2); + + TLatex latex2b; + float l2b = gPad->GetLeftMargin(); + float t2b = gPad->GetTopMargin(); + latex2b.SetTextAlign(11); + latex2b.SetTextSize(0.6*t); + TString cmsText2b = "#font[42]{92.3 fb^{-1} (13 TeV)}"; + // latex2b.DrawLatexNDC(l2b+0.6,1-t2b+0.2*t2b,cmsText2b); + latex2b.DrawLatexNDC(l2b+0.5,1-t2b+0.2*t2b,cmsText2b); + + // Systematic error bands! + if(1) + { + TFile *f2s = TFile::Open("../reminiaodtests/MoreDimuons20172018MCallanglesWithMultiLegacyFinal_SystJanShiftDown.root"); + TFile *f3s = TFile::Open("../reminiaodtests/MoreDimuons20172018MCallanglesWithMultiLegacyFinal_SystJanShiftUp.root"); + // TH1F *h2 = (TH1F *)f2->Get("hressummult"); + // TH1F *h3 = (TH1F *)f3->Get("hressummult"); + + TH1F *hsummultsigshiftd345 = (TH1F *)f2s->Get("hbin3mult45"); + TH1F *hsummultsigshiftd445 = (TH1F *)f2s->Get("hbin4mult45"); + TH1F *hsummultsigshiftd356 = (TH1F *)f2s->Get("hbin3mult56"); + TH1F *hsummultsigshiftd456 = (TH1F *)f2s->Get("hbin4mult56"); + TH1F *hsummultsigshiftu345 = (TH1F *)f3s->Get("hbin3mult45"); + TH1F *hsummultsigshiftu445 = (TH1F *)f3s->Get("hbin4mult45"); + TH1F *hsummultsigshiftu356 = (TH1F *)f3s->Get("hbin3mult56"); + TH1F *hsummultsigshiftu456 = (TH1F *)f3s->Get("hbin4mult56"); + + TH1F *h2 = (TH1F *)hsummultsigshiftd345->Clone("h2"); h2->Add(hsummultsigshiftd445); + h2->Add(hsummultsigshiftd356); h2->Add(hsummultsigshiftd456); + + TH1F *h3 = (TH1F *)hsummultsigshiftu345->Clone("h3"); h3->Add(hsummultsigshiftu445); + h3->Add(hsummultsigshiftu356); h3->Add(hsummultsigshiftu456); + + h2->Rebin(rebinfact); h3->Rebin(rebinfact); + + h2->Scale(theFrac[1] * hall->GetSumOfWeights() / h2->GetSumOfWeights()); + h3->Scale(theFrac[1] * hall->GetSumOfWeights() / h3->GetSumOfWeights()); + + + Int_t nbins = hsig->GetNbinsX(); + Float_t binup[nbins]; + Float_t bindown[nbins]; + Float_t binup2[nbins]; + Float_t bindown2[nbins]; + Float_t binx[nbins]; + Float_t biny[nbins]; + Float_t binxup[nbins]; + Float_t binxdown[nbins]; + + + TH1F *hband = (TH1F *)hsig->Clone("hband"); + + for(Int_t n = 1; n < hsig->GetNbinsX(); n++) + { + Float_t ndef = hsig->GetBinContent(n); + Float_t nup = h3->GetBinContent(n); + Float_t ndown = h2->GetBinContent(n); + + Float_t highshift = TMath::Max(nup,ndown); + Float_t lowshift = TMath::Min(nup,ndown); + + // Float_t high = TMath::Max(highshift,ndef); + // Float_t low = TMath::Min(lowshift,ndef); + Float_t high = TMath::Max(ndown,ndef); + Float_t low = TMath::Min(ndown,ndef); + Float_t high2 = TMath::Max(nup,ndef); + Float_t low2 = TMath::Min(nup,ndef); + + binup[n-1] = high-ndef; + bindown[n-1] = ndef-low; + binup2[n-1] = high2-ndef; + bindown2[n-1] = ndef-low2; + + binxdown[n-1] = (hsig->GetBinWidth(n)/2.0); + binxup[n-1] = (hsig->GetBinWidth(n)/2.0); + binx[n-1] = hsig->GetBinCenter(n); + biny[n-1] = hsig->GetBinContent(n); + } + TGraphAsymmErrors *gr = new TGraphAsymmErrors(nbins,binx,biny,binxdown,binxup,bindown,binup); + TGraphAsymmErrors *gr2 = new TGraphAsymmErrors(nbins,binx,biny,binxdown,binxup,bindown2,binup2); + + gr->SetMarkerStyle(0); gr->SetFillColor(13); gr->SetFillStyle(3004); gr->SetLineStyle(0); //gr->Draw("PE2same"); + gr2->SetMarkerStyle(0); gr2->SetFillColor(13); gr2->SetFillStyle(3005); gr2->SetLineStyle(0); //gr2->Draw("PE2same"); + gr->Draw("E2same"); + gr2->Draw("E2same"); + + hsigerr->Draw("E2same"); + hsig->Draw("histsame"); + // hsub->Draw("E0same"); + hsubasym->Draw("E0same"); + + le2->AddEntry(gr,"#xi systematic uncertainty (shift down)"); + le2->AddEntry(gr2,"#xi systematic uncertainty (shift up)"); + le2->Draw("same"); + + // hband->SetFillColor(13); hband->SetMarkerSize(0); hband->Draw("E2same"); + // h1->SetLineWidth(3); h1->SetLineColor(4); h1->Draw("histsame"); + } + + // -0.4, 0.4 + TString fitopt = "EMVS"; + if(minimizer == 1) + fitopt = "LEMVS"; + + // TF1 *gausfitdat = new TF1("gausfitdat","gaus(0)",-fitrange,fitrange); + // gausfitdat->SetLineColor(2); gausfitdat->SetLineWidth(3); gausfitdat->SetLineStyle(2); + // // TFitResultPtr fitdat1 = hsub->Fit("gausfitdat","LEMVS","",-fitrange,fitrange); + // TFitResultPtr fitdat1 = hsub->Fit("gausfitdat",fitopt,"",-fitrange,fitrange); + // TF1 *gausfitmc = new TF1("gausfitmc","gaus(0)",-fitrange,fitrange); + // gausfitmc->SetLineColor(3); gausfitmc->SetLineWidth(3); + // TFitResultPtr fitmc1 = hsigerr->Fit("gausfitmc","LEMVS","",-fitrange,fitrange); + // std::cout << "# " << hist << ", " << rebinfact << ", " << year << ", " << mode << ", " << pot << ", " << fitrange << std::endl; + // std::cout << "# Data mean and error, MC mean and error , Data sigma and error, MC sigma and error" << std::endl; + // std::cout << gausfitdat->GetParameter(1) << " " + // << gausfitdat->GetParError(1) << " " + // << gausfitmc->GetParameter(1) << " " + // << gausfitmc->GetParError(1) << " " + // << gausfitdat->GetParameter(2) << " " + // << gausfitdat->GetParError(2) << " " + // << gausfitmc->GetParameter(2) << " " + // << gausfitmc->GetParError(2) << std::endl; + + // std::cout << "N(data, gaussian integral) = " << gausfitdat->Integral(-0.5,0.5) << std::endl; + std::cout << "N(sig) = " << hsig->GetSumOfWeights() << std::endl; + std::cout << "N(bkg, -0.15-0.15) = " << nbkgpeak << std::endl; + std::cout << "RMS(sig) = " << hsig->GetRMS() << std::endl; + std::cout << "chi2_BC = " << fit->GetChisquare() << std::endl; + std::cout << "NDF = " << fit->GetNDF() << std::endl; + std::cout << "p(chi2) = " << fit->GetProb() << std::endl; + + // std::cout << "# chi2_BC/NDF (data) = " << gausfitdat->GetChisquare() << "/" + // << gausfitdat->GetNDF() << std::endl; + // std::cout << "# p(chi2, data) = " << gausfitdat->GetProb() << std::endl; + // std::cout << "# chi2_BC/NDF (MC) = " << gausfitmc->GetChisquare() << "/" + // << gausfitmc->GetNDF() << std::endl; + // std::cout << "# p(chi2, MC) = " << gausfitmc->GetProb() << std::endl; + + // Float_t nbkgpeak = hbkg->Integral(hbkg->FindBin(-0.1),hbkg->FindBin(0.1)); + Float_t ndatapeak = hall->Integral(hbkg->FindBin(-0.1),hbkg->FindBin(0.1)); + Float_t nbkgpeak2 = hbkg->Integral(hbkg->FindBin(-0.05),hbkg->FindBin(0.2)); + Float_t ndatapeak2 = hall->Integral(hbkg->FindBin(-0.05),hbkg->FindBin(0.2)); + + std::cout << "Data in 45 signal region = " << ndatapeak << ", bkg in signal region = " << nbkgpeak << std::endl; + std::cout << "Data in 56 signal region = " << ndatapeak2 << ", bkg in signal region = " << nbkgpeak2 << std::endl; + + if(mode == 4) + CMSTOTEM_lumi((TPad*)c2->GetPad(2),0,0,"single-RP"); + if(mode == 5) + { + // CMSTOTEM_lumi((TPad*)c2->GetPad(1),0,0,"multi-RP"); + // CMSTOTEM_lumi((TPad*)c2->GetPad(2),0,0,"multi-RP"); + } +}