diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/CMakeLists.txt b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7a639bd5f23ba7f52116e7ef8db306f5d592b7cd --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/CMakeLists.txt @@ -0,0 +1,34 @@ +################################################################################ +# Package: MuonPerformanceHistUtils +################################################################################ + +# Declare the package name: +atlas_subdir( MuonPerformanceHistUtils ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthToolSupport/AsgTools + Event/xAOD/xAODBase + Event/xAOD/xAODMissingET + Event/xAOD/xAODMuon + Event/xAOD/xAODTruth + GaudiKernel + MuonSpectrometer/MuonValidation/MuonHistogramming/MuonHistUtils + PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections + Tracking/TrkValidation/TrkValHistUtils + PRIVATE + Control/AthenaBaseComps + Event/xAOD/xAODEventInfo + Event/xAOD/xAODTracking ) + +# External dependencies: +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_library( MuonPerformanceHistUtils + Root/*.cxx + PUBLIC_HEADERS MuonPerformanceHistUtils + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools xAODBase xAODMissingET xAODMuon xAODTruth GaudiKernel MuonHistUtils TrkValHistUtils MuonEfficiencyCorrectionsLib + PRIVATE_LINK_LIBRARIES AthenaBaseComps xAODEventInfo xAODTracking ) + diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuTPEventCutFlowPlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/DiLeptonTPEventCutFlowPlots.h similarity index 71% rename from PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuTPEventCutFlowPlots.h rename to PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/DiLeptonTPEventCutFlowPlots.h index 08cb799adac0c6486f0f9a6717b89bf10c899324..cdf8ea96e5f0e2411db605a6be731a00242ab246 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuTPEventCutFlowPlots.h +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/DiLeptonTPEventCutFlowPlots.h @@ -8,9 +8,10 @@ #include "MuonPerformanceHistUtils/MuonTPCutFlowBase.h" #include "TrkValHistUtils/PlotBase.h" -class ZmumuTPEventCutFlowPlots: public MuonTPCutFlowBase { +class DiLeptonTPEventCutFlowPlots: public MuonTPCutFlowBase { public: - ZmumuTPEventCutFlowPlots(PlotBase* pParent, std::string sDir); + DiLeptonTPEventCutFlowPlots(PlotBase* pParent, std::string sDir); + void initializePlots(); private: diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/JPsiBasicTPEfficiencyPlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/JPsiBasicTPEfficiencyPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..0de67d0c0240feab7b0411b5ac68e637e41345a0 --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/JPsiBasicTPEfficiencyPlots.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JPSIBASICTPEFFICIENCYPLOTS_H +#define JPSIBASICTPEFFICIENCYPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "MuonPerformanceHistUtils/MuonTPEfficiencyPlotBase.h" + +#include "MuonPerformanceHistUtils/Probe.h" +#include "MuonEfficiencyCorrections/fineEtaPhiBinning.h" + +class JPsiBasicTPEfficiencyPlots: public MuonTPEfficiencyPlotBase { + public: + JPsiBasicTPEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF=false); + + + void initializePlots(); + void fill(Probe& probe); + + private: + + bool m_isMatched; + TH1* pt; + TH1* eta; + TH1* phi; + TH1* d0; + // TH1* phi; + TH1* fineEtaPhi; + TH1* integrated; + fineEtaPhiBinning m_fepb; + +}; + +#endif // JPSIBASICTPEFFICIENCYPLOTS_H diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/JPsiTPEventCutFlowPlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/JPsiTPEventCutFlowPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..44eb48b0b2f4993bc365d692908ec6a767acf23b --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/JPsiTPEventCutFlowPlots.h @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JPSITPEVENTCUTFLOWPLOTS_H +#define JPSITPEVENTCUTFLOWPLOTS_H + +#include "MuonPerformanceHistUtils/MuonTPCutFlowBase.h" +#include "TrkValHistUtils/PlotBase.h" + +class JPsiTPEventCutFlowPlots: public MuonTPCutFlowBase { + public: + JPsiTPEventCutFlowPlots(PlotBase* pParent, std::string sDir); + + private: + + TH1* tp_main_selection; + TH1* tp_tag_selection; + TH1* tp_probe_selection; + +}; + +#endif // JPSITPEVENTCUTFLOWPLOTS_H diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/JPsiTagProbeDileptonPlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/JPsiTagProbeDileptonPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..d11e905eca682384dc7e8a17512ce4872b712393 --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/JPsiTagProbeDileptonPlots.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JPSITAGPROBEDILEPTONPLOTS_H +#define JPSITAGPROBEDILEPTONPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "MuonPerformanceHistUtils/MuonTPEfficiencyPlotBase.h" + +#include "MuonPerformanceHistUtils/Probe.h" + +class JPsiTagProbeDileptonPlots: public MuonTPEfficiencyPlotBase { + + public: + + JPsiTagProbeDileptonPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF=false); + + void initializePlots(); + void fill(Probe& probe); + + private: + + bool m_isMatched; + + TH1* m_ll; + TH1* opening_angle; + TH1* jpsi_pt; + + TH3* pem_num; + TH3* pem_num_etaq; + + TH3* fem_num; + TH3* fem_num_etaq; + + TH3* pfm_num; + + long double pi = TMath::Pi(); + +}; + +#endif // JPSITAGPROBEDILEPTONPLOTS_H diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonResonancePlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonResonancePlots.h index 1d68d91cd546befaecb65a70372504a43ce5052b..f2d76bbada3431cec55c9ce45ec9e663568dba2c 100755 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonResonancePlots.h +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonResonancePlots.h @@ -70,18 +70,23 @@ class MuonResonancePlots: public PlotBase { DeltaZ_m_etaphi(NULL), DeltaZ_m_q_etaphi(NULL), p_pTRUE_etapt(NULL), - p_pTRUE_etaphi(NULL) + p_pTRUE_etaphi(NULL), + suffix(""), + prefix(""), + fGeV(1.0) + {;} TString selitool; const double M_pdg[3] = {91187.6, 3096.6, 9460.3}; const double Pi = TMath::Pi(); + void useGeV(bool u){if (u) fGeV=1000.0; else fGeV=1.0;} void setSuffix(std::string suff){suffix=suff;}; void setPrefix(std::string pref){prefix=pref;}; void setBinning(std::map< std::string,std::vector<double> >); void BookPlots(); - void fill(const xAOD::Muon& mu1st, const xAOD::Muon& mu2nd, int trk); + void fill(const xAOD::Muon& mu1st, const xAOD::Muon& mu2nd, int trk=-1); float M0(); float p_star(TLorentzVector v1, TLorentzVector v2); float deltaPt(TLorentzVector v1, TLorentzVector v2); @@ -95,7 +100,6 @@ class MuonResonancePlots: public PlotBase { void PrintVectors(TLorentzVector l1, TLorentzVector l2, TLorentzVector V, TLorentzVector l1_truth, TLorentzVector l2_truth, TLorentzVector V_truth, int type, float weight); - //Histograms TH1* mu_1stAuthor; TH1* mu_2ndAuthor; @@ -172,6 +176,8 @@ class MuonResonancePlots: public PlotBase { void initializePlots(); std::string suffix; std::string prefix; + float fGeV; + void Binning1D(TH1*& histo,std::string hname); void Binning2D(TH2*& histo,std::string hname); void Fill1D(TH1*& histo, float x, float w); diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonTrigTPEfficiencyPlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonTrigTPEfficiencyPlots.h index 84e49643260438e986c13c63400e8faf861229de..6c5fe4908bcecc3349e97c60b2d9944180c550c0 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonTrigTPEfficiencyPlots.h +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonTrigTPEfficiencyPlots.h @@ -30,15 +30,11 @@ class MuonTrigTPEfficiencyPlots: public MuonTPEfficiencyPlotBase bool m_isMatched; - TH1* pt; + TH1* pt; //inclusive larger muon Pt TH1* eta; TH1* phi; - TH2* eta_phi; - TH1* dRL1; - TH1* dRHLT; - TH1* mll; }; diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonWCandidatePlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonWCandidatePlots.h new file mode 100755 index 0000000000000000000000000000000000000000..282d314dbabaf66240088e1960b0a71078d3e33d --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/MuonWCandidatePlots.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUONHISTUTILS_MUONWCANDIDATEPLOTS_H +#define MUONHISTUTILS_MUONWCANDIDATEPLOTS_H + +#include "TrkValHistUtils/PlotBase.h" +#include "xAODMuon/Muon.h" +#include "xAODMissingET/MissingET.h" +#include <string> + +class MuonWCandidatePlots: public PlotBase +{ + public: + MuonWCandidatePlots(PlotBase *pParent, std::string sDir); + void fill(const xAOD::Muon& mu, const xAOD::MissingET& met); + + TH1* me_t; + TH1* me_x; + TH1* me_y; + + TH1* mu_pt; + TH1* mu_eta; + TH1* mu_phi; + + TH1* w_pt; + TH1* w_phi; + TH1* w_mt; + + private: + void initializePlots(); +}; + +#endif diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/Probe.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/Probe.h index 42a87d80c520fd93bb332c70360b728f7b23e3a6..b460a549bda7e57609432bdf0a7384089455f868 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/Probe.h +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/Probe.h @@ -14,6 +14,7 @@ class Probe { // constructor Probe(const xAOD::IParticle& tagTrack, const xAOD::IParticle& probeTrack); + Probe(const xAOD::IParticle& tagTrack, const xAOD::IParticle& probeTrack, int tagPassTrigger); // destructor ~Probe(); @@ -38,6 +39,8 @@ class Probe { // set probe matching status void isMatched(bool isM) {m_isMatched = isM;} + // set probe closest match dr + void dr_match(float in){ m_dr_match = in;} float sfweight(){ return m_sf_weight;} void sfweight(float w ){ m_sf_weight = w;} @@ -52,6 +55,10 @@ class Probe { bool HasSomeTrigger_HLT(void) { return m_HasSomeTrigger_HLT; } void HasSomeTrigger_HLT(bool in) { m_HasSomeTrigger_HLT = in; } + int tagPassTrigger(){ return m_tagPassTrigger;} + + double dr_match() {return m_dr_match;} + float dRL1; float dRHLT; @@ -63,6 +70,9 @@ class Probe { const xAOD::IParticle& m_probeTrack; float m_sf_weight; // for closure tests + float m_dr_match; // dR distance to closest match + + int m_tagPassTrigger; // trigger stuff std::string m_CurrentTrigger; diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuBasicTPEfficiencyPlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuBasicTPEfficiencyPlots.h index 8077f4e2656ae57250c5abee4419c13b13ac4d5b..19cd1ce49dec1eaad43f60efaf0b10099b966c53 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuBasicTPEfficiencyPlots.h +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuBasicTPEfficiencyPlots.h @@ -13,9 +13,9 @@ class ZmumuBasicTPEfficiencyPlots: public MuonTPEfficiencyPlotBase { public: - ZmumuBasicTPEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF=false); - + ZmumuBasicTPEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF=false); + void initializePlots(); void fill(Probe& probe); private: diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuDetRegionEfficiencyPlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuDetRegionEfficiencyPlots.h index d31b5b6602c253c78c465b9c610bb36e8f5a83d5..d9170d3b270f885903fabcd18a31e12248c55312 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuDetRegionEfficiencyPlots.h +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuDetRegionEfficiencyPlots.h @@ -18,6 +18,7 @@ class ZmumuDetRegionEfficiencyPlots: public MuonTPEfficiencyPlotBase { ZmumuDetRegionEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF=false); + void initializePlots(); void fill(Probe& probe); private: diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuFineEtaPhiEfficiencyPlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuFineEtaPhiEfficiencyPlots.h index ce45d184336062e959158d92f2fb4e1ced25f554..9b3e055cfefc1231f93bb3cf870c1d8b014d7ab3 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuFineEtaPhiEfficiencyPlots.h +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuFineEtaPhiEfficiencyPlots.h @@ -15,9 +15,9 @@ class ZmumuFineEtaPhiEfficiencyPlots: public MuonTPEfficiencyPlotBase { public: - ZmumuFineEtaPhiEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF=false); - + ZmumuFineEtaPhiEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF=false); + void initializePlots(); void fill(Probe& probe); private: diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuTagProbeDileptonPlots.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuTagProbeDileptonPlots.h index c1add74104c745b94bd52819e5f162f796228218..5c36fe12262b7891d5952ac3d4e42179d34e09fe 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuTagProbeDileptonPlots.h +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/MuonPerformanceHistUtils/ZmumuTagProbeDileptonPlots.h @@ -12,9 +12,9 @@ class ZmumuTagProbeDileptonPlots: public MuonTPEfficiencyPlotBase { public: - ZmumuTagProbeDileptonPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF=false); - + ZmumuTagProbeDileptonPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF=false); + void initializePlots(); void fill(Probe& probe); private: diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/DiLeptonTPEventCutFlowPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/DiLeptonTPEventCutFlowPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e442e44c064160b291a098f61ffaea28e9c59a95 --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/DiLeptonTPEventCutFlowPlots.cxx @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/* + * ZmumuBasicTPEfficiencyPlots.cxx + * + * Created on: Sep 2, 2014 + * Author: goblirsc + */ + +#include "MuonPerformanceHistUtils/DiLeptonTPEventCutFlowPlots.h" + +DiLeptonTPEventCutFlowPlots::DiLeptonTPEventCutFlowPlots(PlotBase* pParent, std::string sDir) + : MuonTPCutFlowBase (pParent, sDir) {} + +void DiLeptonTPEventCutFlowPlots::initializePlots() +{ + std::vector<std::string> main_cf_steps; + main_cf_steps.push_back("Processed"); + main_cf_steps.push_back("GRL"); + main_cf_steps.push_back("Trigger"); + main_cf_steps.push_back("HaveTag"); + main_cf_steps.push_back("HaveProbe"); + tp_main_selection = AddCutFlow("MainSelection",main_cf_steps); + for (auto step: main_cf_steps) { + tp_main_selection->Fill(step.c_str(), 0); // fill once to avoid merging issues + } + + std::vector<std::string> tag_cf_steps; + tag_cf_steps.push_back("TagCandidates"); + tag_cf_steps.push_back("TagQuality"); + tag_cf_steps.push_back("TagPt"); + tag_cf_steps.push_back("TagEta"); + tag_cf_steps.push_back("TagTrigger"); + tag_cf_steps.push_back("TagIP"); + tag_cf_steps.push_back("TagIsolation"); + tp_tag_selection = AddCutFlow("TagSelection",tag_cf_steps); + for (auto step: tag_cf_steps) { + tp_tag_selection->Fill(step.c_str(), 0); // fill once to avoid merging issues + } + + std::vector<std::string> probe_cf_steps; + probe_cf_steps.push_back("ProbeCandidates"); + probe_cf_steps.push_back("ProbeKinematics"); + probe_cf_steps.push_back("ProbeQuality"); + probe_cf_steps.push_back("ProbeIP"); + probe_cf_steps.push_back("ProbeIsolation"); + probe_cf_steps.push_back("ProbeInvMass"); + probe_cf_steps.push_back("ProbeDeltaPhi"); + tp_probe_selection = AddCutFlow("ProbeSelection",probe_cf_steps); + for (auto step: probe_cf_steps) { + tp_probe_selection->Fill(step.c_str(), 0); // fill once to avoid merging issues + } +} + diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/JPsiBasicTPEfficiencyPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/JPsiBasicTPEfficiencyPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6a8967aab561be881b00dc1d3d929d09970495bb --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/JPsiBasicTPEfficiencyPlots.cxx @@ -0,0 +1,66 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/* + * JPsiMuonTPSelectionTool.cxx + * + * Created on: Dec 22, 2014 + * Adapted for J/Psi by Maximiliano Sioli + * + */ + +#include "MuonPerformanceHistUtils/JPsiBasicTPEfficiencyPlots.h" +#include "xAODTracking/TrackParticle.h" +#include "xAODMuon/Muon.h" + +JPsiBasicTPEfficiencyPlots::JPsiBasicTPEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF) + : MuonTPEfficiencyPlotBase (pParent, sDir, isMatched, ApplySF), + m_isMatched(isMatched) {} + + +void JPsiBasicTPEfficiencyPlots::initializePlots() +{ + // 23 variable-size bins in pt + double ptbins[] = {0., 0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6., 6.5, 7., 7.5, 8., 9., 10., 12., 14., 16., 18., 20.}; + + int nptbins = sizeof (ptbins) / sizeof (double) - 1; + TH1D ptdummy ("ptdummy","dummy",nptbins,ptbins) ; + pt = Book1D("pt" ,&ptdummy, " pt; Transverse Momentum [GeV];Entries / 1 GeV"); + + // 25 fixed-size bins in eta + eta = Book1D("eta" ," eta; #eta; Entries ",25,-2.5,2.5); + + // 25 fixed-size bins in phi + phi = Book1D("phi" ," phi; #phi; Entries ",25,-TMath::Pi(),TMath::Pi()); + + d0 = Book1D("d0" ," d0; d_{0} [mm]; Entries ",200,-10,10); + integrated = Book1D("integrated" ," integrated; ; Entries ",1,0.5,1.5); + fineEtaPhi = Book1D("fineEtaPhi" ," fineEtaPhi; fine (#eta, #phi) bin; Entries ",m_fepb.nbins(),m_fepb.firstbin()-0.5, m_fepb.lastbin()+0.5); +} + + +void JPsiBasicTPEfficiencyPlots::fill(Probe& probe) +{ + if(m_isMatched && !probe.isMatched()) return; + float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); + pt->Fill(probe.pt() / 1000.,sfweight); + eta->Fill(probe.eta() ,sfweight); + phi->Fill(probe.phi() ,sfweight); + integrated->Fill(1,sfweight); + + // case 1: ID track + const xAOD::TrackParticle* trk = dynamic_cast<const xAOD::TrackParticle*>(&(probe.probeTrack())); + + // in case that didn't work, try a muon! + if (!trk) { + const xAOD::Muon* mu = dynamic_cast<const xAOD::Muon*> (&(probe.probeTrack())); + if (mu && mu->primaryTrackParticle()) trk = mu->primaryTrackParticle(); + if (!trk && mu && *(mu->inDetTrackParticleLink())) trk = *(mu->inDetTrackParticleLink()); + } + if (trk) d0->Fill(trk->d0(),sfweight); + + + fineEtaPhi->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); + +} diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuTPEventCutFlowPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/JPsiTPEventCutFlowPlots.cxx similarity index 85% rename from PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuTPEventCutFlowPlots.cxx rename to PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/JPsiTPEventCutFlowPlots.cxx index 743653c35e443f176c69686ae3aaaab423faee3b..ef5c9757cfa36bdc7e3ea274ebb3564aeeb17953 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuTPEventCutFlowPlots.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/JPsiTPEventCutFlowPlots.cxx @@ -3,19 +3,21 @@ */ /* - * ZmumuBasicTPEfficiencyPlots.cxx + * JPsiMuonTPSelectionTool.cxx + * + * Created on: Dec 22, 2014 + * Adapted for J/Psi by Maximiliano Sioli * - * Created on: Sep 2, 2014 - * Author: goblirsc */ -#include "MuonPerformanceHistUtils/ZmumuTPEventCutFlowPlots.h" +#include "MuonPerformanceHistUtils/JPsiTPEventCutFlowPlots.h" -ZmumuTPEventCutFlowPlots::ZmumuTPEventCutFlowPlots(PlotBase* pParent, std::string sDir) +JPsiTPEventCutFlowPlots::JPsiTPEventCutFlowPlots(PlotBase* pParent, std::string sDir) : MuonTPCutFlowBase (pParent, sDir) { std::vector<std::string> main_cf_steps; main_cf_steps.push_back("Processed"); + main_cf_steps.push_back("GRL"); main_cf_steps.push_back("Trigger"); main_cf_steps.push_back("HaveTag"); main_cf_steps.push_back("HaveProbe"); diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/JPsiTagProbeDileptonPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/JPsiTagProbeDileptonPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0dd11a7c93c10c0a49265f50c61a702701b72604 --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/JPsiTagProbeDileptonPlots.cxx @@ -0,0 +1,145 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/* + * JPsiBasicTPEfficiencyPlots.cxx + * + * Created on: Dec 22, 2014 + * Author: Maximiliano Sioli + */ + +#include "xAODTracking/TrackParticle.h" +#include "xAODMuon/Muon.h" +#include "xAODTracking/VertexContainer.h" +#include "MuonPerformanceHistUtils/JPsiTagProbeDileptonPlots.h" + +JPsiTagProbeDileptonPlots::JPsiTagProbeDileptonPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF) +: MuonTPEfficiencyPlotBase (pParent, sDir, isMatched, ApplySF), + m_isMatched(isMatched) {} + +void JPsiTagProbeDileptonPlots::initializePlots() +{ + m_ll = Book1D("m_ll","mll; m_{ll} [GeV]; Entries",250,2000.,4500.); + opening_angle = Book1D("opening_angle","opening_angle; Dilepton opening angle; Entries",40,0.0,TMath::Pi()); + jpsi_pt = Book1D("jpsi_pt","jpsi_pt; JPsi p_{T} [GeV] ; Entries",100,0.0,50000.); + + // const double pi = 3.141592653589; + + // 23 variable-size bins in pt + double bins_p[] = {0., 0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6., 6.5, 7., 7.5, 8., 9., 10., 12., 14., 16., 18., 20.}; + + // 25 fixed-size bins in eta + double min_e = -2.5; + double max_e = 2.5; + int nBins_e = 25; + double step_e = (max_e-min_e)/nBins_e; // 0.2 eta units + double bins_e[26]; + + double tmp = min_e; + int i = 0; + while (tmp < max_e) { + bins_e[i] = tmp; + tmp += step_e; + i++; + } + bins_e[i] = max_e; + + // 25 fixed-size bins in phi + + double min_f = -pi; + double max_f = pi; + int nBins_f = 25; + double step_f = (max_f-min_f)/nBins_f; // ~0.25 rad + double bins_f[26]; + + tmp = min_f; + i = 0; + while (tmp < max_f) { + bins_f[i] = tmp; + tmp += step_f; + i++; + } + bins_f[i] = max_f; + + // 200 fixed-size bins in mll + + double min_m = 2.0; + double max_m = 4.5; + int nBins_m = 200; + double step_m = (max_m-min_m)/nBins_m; // 12.5 MeV + double bins_m[201]; + + tmp = min_m; + i = 0; + while (tmp < max_m) { + bins_m[i] = tmp; + tmp += step_m; + i++; + } + bins_m[i] = max_m; + + int n_bins_p = sizeof (bins_p) / sizeof (double) - 1; + int n_bins_e = sizeof (bins_e) / sizeof (double) - 1; + int n_bins_f = sizeof (bins_f) / sizeof (double) - 1; + int n_bins_m = sizeof (bins_m) / sizeof (double) - 1; + + // std::cout << "eccolo: " << n_bins_f << " " << bins_f[0] << " " << bins_f[n_bins_f+1] << std::endl; + + TH3D pem_dummy ("pem_dummy","pemdummy", n_bins_p, bins_p, n_bins_e, bins_e, n_bins_m, bins_m); + TH3D pem_dummy_etaq ("pem_dummy_etaq","pemdummy_etaq", n_bins_p, bins_p, n_bins_e, bins_e, n_bins_m, bins_m); + + TH3D fem_dummy ("fem_dummy","femdummy", n_bins_f, bins_f, n_bins_e, bins_e, n_bins_m, bins_m); + TH3D fem_dummy_etaq ("fem_dummy_etaq","femdummy_etaq", n_bins_f, bins_f, n_bins_e, bins_e, n_bins_m, bins_m); + + TH3D pfm_dummy ("pfm_dummy","pfmdummy", n_bins_p, bins_p, n_bins_f, bins_f, n_bins_m, bins_m); + + pem_num = PlotBase::Book3D("_pem_num", &pem_dummy, "pem_num; p_{T} [GeV]; eta; m_{ll} [GeV]; Entries"); + pem_num_etaq = PlotBase::Book3D("_pem_num_etaq", &pem_dummy_etaq, "pem_num_etaq; p_{T} [GeV]; eta*Q; m_{ll} [GeV]; Entries"); + + fem_num = PlotBase::Book3D("_fem_num", &fem_dummy, "fem_num; phi; eta; m_{ll} [GeV]; Entries"); + fem_num_etaq = PlotBase::Book3D("_fem_num_etaq", &fem_dummy_etaq, "fem_num_etaq; phi; eta*Q; m_{ll} [GeV]; Entries"); + + pfm_num = PlotBase::Book3D("_pfm_num", &pfm_dummy, "pfm_num; p_{T} [GeV]; phi; m_{ll} [GeV]; Entries"); + +} + + +void JPsiTagProbeDileptonPlots::fill(Probe& probe) +{ + + if(m_isMatched && !probe.isMatched()) return; + + float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); + TLorentzVector z = probe.probeTrack().p4() + probe.tagTrack().p4(); + + m_ll->Fill(z.M(),sfweight ); + jpsi_pt->Fill(z.Pt(),sfweight); + opening_angle->Fill(fabs(probe.probeTrack().p4().Angle(probe.tagTrack().p4().Vect())),sfweight); + + float vtx_mass = z.M(); + float probePt = probe.pt(); + float probeEta = probe.eta(); + float probePhi = probe.phi(); + + int probeQ = 1000; + + // case of a muon probe + const xAOD::Muon* muprobe = dynamic_cast<const xAOD::Muon*>(&probe.probeTrack()); + if (muprobe) probeQ = muprobe->trackParticle(xAOD::Muon::Primary)->charge(); + + // case of an ID probe + const xAOD::TrackParticle* trkprobe = dynamic_cast<const xAOD::TrackParticle*>(&probe.probeTrack()); + if (trkprobe) probeQ = trkprobe->charge(); + + if ( probeQ < 1000 ) { + pem_num->Fill(probePt/1000., probeEta, vtx_mass/1000., sfweight); + pem_num_etaq->Fill(probePt/1000., probeEta*probeQ, vtx_mass/1000., sfweight); + + fem_num->Fill(probePhi, probeEta, vtx_mass/1000., sfweight); + fem_num_etaq->Fill(probePhi, probeEta*probeQ, vtx_mass/1000., sfweight); + + pfm_num->Fill(probePt/1000., probePhi, vtx_mass/1000., sfweight); + } + +} diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonResonancePlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonResonancePlots.cxx index a3a408edcdc72708531c9b5db657d7ef3c82146d..93604f0dcf7752fd3315228aa9cd1df775abc5e8 100755 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonResonancePlots.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonResonancePlots.cxx @@ -13,11 +13,11 @@ #endif #include "xAODEventInfo/EventInfo.h" +#include <iostream> void MuonResonancePlots::initializePlots(){ - + std::cout<<"booking MuonResonancePlots"<<std::endl; BookPlots(); - } void MuonResonancePlots::setBinning(std::map<std::string, std::vector<double> > bins ){ m_binning=bins;} @@ -142,6 +142,15 @@ void MuonResonancePlots::BookPlots(){ } void MuonResonancePlots::fill(const xAOD::Muon& mu1st, const xAOD::Muon& mu2nd, int trk){ + + if(trk==0 && ( !mu1st.trackParticle(xAOD::Muon::CombinedTrackParticle) + || !mu2nd.trackParticle(xAOD::Muon::CombinedTrackParticle) ) ) return; + + if(trk==1 && ( !mu1st.trackParticle(xAOD::Muon::InnerDetectorTrackParticle) + || !mu2nd.trackParticle(xAOD::Muon::InnerDetectorTrackParticle) ) ) return; + + if(trk==2 && ( !mu1st.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle) + || !mu2nd.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle) ) ) return; TLorentzVector V,l1,l2; l1 = sortedPair(getTrackTLV(mu1st, trk), getTrackTLV(mu2nd, trk)).first; @@ -159,72 +168,72 @@ void MuonResonancePlots::fill(const xAOD::Muon& mu1st, const xAOD::Muon& mu2nd, // bool do_print = false; // if(do_print) PrintVectors(l1, l2, V, l1_truth, l2_truth, V_truth, trk, w); - + // Filling histos Fill1D( mu_1stAuthor, int(mu1st.author()), w); Fill1D( mu_2ndAuthor, int(mu2nd.author()), w); - - Fill1D( mu_1stPt, l1.Pt(), w); - Fill1D( mu_2ndPt, l2.Pt(), w); - Fill1D( mu_avPt, (l1.Pt()+l2.Pt())*0.5, w); + + Fill1D( mu_1stPt, l1.Pt()/fGeV, w); + Fill1D( mu_2ndPt, l2.Pt()/fGeV, w); + Fill1D( mu_avPt, (l1.Pt()+l2.Pt())*0.5/fGeV, w); Fill1D( mu_1stPhi, l1.Phi(), w); Fill1D( mu_2ndPhi, l2.Phi(), w); Fill1D( mu_1stEta, l1.Eta(), w); Fill1D( mu_2ndEta, l2.Eta(), w); - - Fill1D( Mmumu, V.M(), w); - Fill1D( Z_pt, V.Pt(), w); + + Fill1D( Mmumu, V.M()/fGeV, w); + Fill1D( Z_pt, V.Pt()/fGeV, w); Fill1D( Z_phi, V.Phi(), w); - - Fill2D( h_Zpt_mu_1stPt, l1.Pt(), V.Pt(), w); - Fill2D( h_mu_1stPt_1stPhi, l1.Phi(), l1.Pt(), w); - Fill2D( h_mu_2ndPt_2ndPhi, l2.Phi(), l2.Pt(), w); - Fill2D( h_Zpt_mu_avPt, (l1.Pt()+l2.Pt())*0.5, V.Pt(), w); - - Fill2D( h_Zm_1stPhi, l1.Phi(), V.M(), w); - Fill2D( h_Zm_2ndPhi, l2.Phi(), V.M(), w); - Fill2D( h_Zm_1stEta, l1.Eta(), V.M(), w); - Fill2D( h_Zm_2ndEta, l2.Eta(), V.M(), w); - Fill2D( h_Zm_1stPt, l1.Pt(), V.M(), w); - Fill2D( h_Zm_2ndPt, l2.Pt(), V.M(), w); - Fill2D( h_Zm_mu_avPt, (l1.Pt()+l2.Pt())*0.5, V.M(), w); - Fill2D( h_Zm_Pexp, p_star(l1, l2), V.M(), w); - - Fill2D( h_Zm_1stPhi_truth, l1.Phi(), V_truth.M(), w); - Fill2D( h_Zm_2ndPhi_truth, l2.Phi(), V_truth.M(), w); - Fill2D( h_Zm_1stEta_truth, l1.Eta(), V_truth.M(), w); - Fill2D( h_Zm_2ndEta_truth, l2.Eta(), V_truth.M(), w); - Fill2D( h_Zm_1stPt_truth, l1.Pt(), V_truth.M(), w); - Fill2D( h_Zm_2ndPt_truth, l2.Pt(), V_truth.M(), w); - Fill2D( h_Zm_mu_avPt_truth, (l1.Pt()+l2.Pt())*0.5, V_truth.M(), w); - Fill2D( h_Zm_Pexp_truth, p_star(l1,l2), V_truth.M(), w); - - Fill2D( Res_mu_1stPt_2D, l1_truth.Pt(), l1.Pt()-l1_truth.Pt(), w); - Fill2D( Res_mu_2ndPt_2D, l2_truth.Pt(), l2.Pt()-l2_truth.Pt(), w); - Fill2D( Res_mu_1stPhi_2D, l1_truth.Phi(), l1.Phi()-l1_truth.Phi(), w); - Fill2D( Res_mu_2ndPhi_2D, l2_truth.Phi(), l2.Phi()-l2_truth.Phi(), w); - Fill2D( Res_mu_1stEta_2D, l1_truth.Eta(), l1.Eta()-l1_truth.Eta(), w); - Fill2D( Res_mu_2ndEta_2D, l2_truth.Eta(), l2.Eta()-l2_truth.Eta(), w); - - Fill2D( Res_Zm_2D, V_truth.M(), V.M()-V_truth.M(), w); - Fill2D( Res_Zm_Eta_2D, l1.Eta(), V.M()-V_truth.M(), w); - Fill2D( Res_Zm_Phi_2D, l1.Phi(), V.M()-V_truth.M(), w); - Fill2D( Res_Zm_Pt_2D, l1.Pt(), V.M()-V_truth.M(), w); - Fill2D( Res_Zm_Pexp_2D, p_star(l1,l2), V.M()-V_truth.M(), w); - Fill2D( Res_Zpt_2D, V_truth.Pt(), V.Pt()-V_truth.Pt(), w); - Fill2D( Res_Zphi_2D, V_truth.Phi(), V.Phi()-V_truth.Phi(), w); - + + Fill2D( h_Zpt_mu_1stPt, l1.Pt()/fGeV, V.Pt()/fGeV, w); + Fill2D( h_mu_1stPt_1stPhi, l1.Phi(), l1.Pt()/fGeV, w); + Fill2D( h_mu_2ndPt_2ndPhi, l2.Phi(), l2.Pt()/fGeV, w); + Fill2D( h_Zpt_mu_avPt, (l1.Pt()+l2.Pt())*0.5/fGeV, V.Pt()/fGeV, w); + + Fill2D( h_Zm_1stPhi, l1.Phi(), V.M()/fGeV, w); + Fill2D( h_Zm_2ndPhi, l2.Phi(), V.M()/fGeV, w); + Fill2D( h_Zm_1stEta, l1.Eta(), V.M()/fGeV, w); + Fill2D( h_Zm_2ndEta, l2.Eta(), V.M()/fGeV, w); + Fill2D( h_Zm_1stPt, l1.Pt()/fGeV, V.M()/fGeV, w); + Fill2D( h_Zm_2ndPt, l2.Pt()/fGeV, V.M()/fGeV, w); + Fill2D( h_Zm_mu_avPt, (l1.Pt()+l2.Pt())*0.5/fGeV, V.M()/fGeV, w); + Fill2D( h_Zm_Pexp, p_star(l1, l2), V.M()/fGeV, w); + + Fill2D( h_Zm_1stPhi_truth, l1.Phi(), V_truth.M()/fGeV, w); + Fill2D( h_Zm_2ndPhi_truth, l2.Phi(), V_truth.M()/fGeV, w); + Fill2D( h_Zm_1stEta_truth, l1.Eta(), V_truth.M()/fGeV, w); + Fill2D( h_Zm_2ndEta_truth, l2.Eta(), V_truth.M()/fGeV, w); + Fill2D( h_Zm_1stPt_truth, l1.Pt()/fGeV, V_truth.M()/fGeV, w); + Fill2D( h_Zm_2ndPt_truth, l2.Pt()/fGeV, V_truth.M()/fGeV, w); + Fill2D( h_Zm_mu_avPt_truth, (l1.Pt()+l2.Pt())*0.5/fGeV, V_truth.M()/fGeV, w); + Fill2D( h_Zm_Pexp_truth, p_star(l1,l2), V_truth.M()/fGeV, w); + + Fill2D( Res_mu_1stPt_2D, l1_truth.Pt()/fGeV, l1.Pt()-l1_truth.Pt()/fGeV, w); + Fill2D( Res_mu_2ndPt_2D, l2_truth.Pt()/fGeV, l2.Pt()-l2_truth.Pt()/fGeV, w); + Fill2D( Res_mu_1stPhi_2D, l1_truth.Phi(), l1.Phi()-l1_truth.Phi(), w); + Fill2D( Res_mu_2ndPhi_2D, l2_truth.Phi(), l2.Phi()-l2_truth.Phi(), w); + Fill2D( Res_mu_1stEta_2D, l1_truth.Eta(), l1.Eta()-l1_truth.Eta(), w); + Fill2D( Res_mu_2ndEta_2D, l2_truth.Eta(), l2.Eta()-l2_truth.Eta(), w); + + Fill2D( Res_Zm_2D, V_truth.M()/fGeV, (V.M()-V_truth.M())/fGeV, w); + Fill2D( Res_Zm_Eta_2D, l1.Eta(), (V.M()-V_truth.M())/fGeV, w); + Fill2D( Res_Zm_Phi_2D, l1.Phi(), (V.M()-V_truth.M())/fGeV, w); + Fill2D( Res_Zm_Pt_2D, l1.Pt()/fGeV, (V.M()-V_truth.M())/fGeV, w); + Fill2D( Res_Zm_Pexp_2D, p_star(l1,l2), (V.M()-V_truth.M())/fGeV, w); + Fill2D( Res_Zpt_2D, V_truth.Pt()/fGeV, (V.Pt()-V_truth.Pt())/fGeV, w); + Fill2D( Res_Zphi_2D, V_truth.Phi(), V.Phi()-V_truth.Phi(), w); + FillTwice( ChiSquared, getChiSquared(mu1st,trk), getChiSquared(mu2nd,trk), w); - FillTwice( p_pTRUE, deltaPt(l1, l1_truth), deltaPt(l2, l2_truth), w); - FillTwice( pID_pME, deltaPt(getTrackTLV(mu1st, 1), getTrackTLV(mu1st, 2)), deltaPt(getTrackTLV(mu2nd, 1), getTrackTLV(mu2nd, 2)), w); - - Fill2D( Z_m_etaphi, l1.Eta(), l1.Phi(), V.M()); - Fill2D( DeltaZ_m_etaphi, l1.Eta(), l1.Phi(), (V.M()-M0())/M0()); - Fill2D( DeltaZ_m_q_etaphi, l1.Eta(), l1.Phi(), mu1st.charge()*(V.M()-M0())/M0()); - Fill2D( p_pTRUE_etapt, l1.Eta(), l1.Pt(), deltaPt(l1, l1_truth) ); - Fill2D( p_pTRUE_etapt, l2.Eta(), l2.Pt(), deltaPt(l2, l2_truth) ); - Fill2D( p_pTRUE_etaphi, l1.Eta(), l1.Phi(), deltaPt(l1, l1_truth) ); - Fill2D( p_pTRUE_etaphi, l2.Eta(), l2.Phi(), deltaPt(l2, l2_truth) ); + FillTwice( p_pTRUE, deltaPt(l1, l1_truth), deltaPt(l2, l2_truth), w); + FillTwice( pID_pME, deltaPt(getTrackTLV(mu1st, 1), getTrackTLV(mu1st, 2)), deltaPt(getTrackTLV(mu2nd, 1), getTrackTLV(mu2nd, 2)), w); + + Fill2D( Z_m_etaphi, l1.Eta(), l1.Phi(), V.M()/fGeV); + Fill2D( DeltaZ_m_etaphi, l1.Eta(), l1.Phi(), (V.M()-M0())/M0()); + Fill2D( DeltaZ_m_q_etaphi, l1.Eta(), l1.Phi(), mu1st.charge()*(V.M()-M0())/M0()); + Fill2D( p_pTRUE_etapt, l1.Eta(), l1.Pt()/fGeV, deltaPt(l1, l1_truth) ); + Fill2D( p_pTRUE_etapt, l2.Eta(), l2.Pt()/fGeV, deltaPt(l2, l2_truth) ); + Fill2D( p_pTRUE_etaphi, l1.Eta(), l1.Phi(), deltaPt(l1, l1_truth) ); + Fill2D( p_pTRUE_etaphi, l2.Eta(), l2.Phi(), deltaPt(l2, l2_truth) ); return; } @@ -234,18 +243,10 @@ void MuonResonancePlots::fill(const xAOD::Muon& mu1st, const xAOD::Muon& mu2nd, const xAOD::TruthParticle* MuonResonancePlots::findTruthMuon(const xAOD::Muon& mu){ const xAOD::TruthParticle *truthMu = 0; - const xAOD::TrackParticle* tp = const_cast<xAOD::TrackParticle*>(mu.primaryTrackParticle()); - - if( mu.muonType() == xAOD::Muon::Combined && !tp ) - tp = const_cast<xAOD::TrackParticle*>((*mu.inDetTrackParticleLink())); - - if(tp){ - typedef ElementLink< xAOD::TruthParticleContainer > MuonLink; - if(!tp->isAvailable< MuonLink >("truthParticleLink")) return truthMu; - MuonLink truthLink = tp->auxdata< MuonLink >("truthParticleLink"); - if(!truthLink.isValid() ) return truthMu; - truthMu = (*truthLink); - } + if(!mu.isAvailable<ElementLink<xAOD::TruthParticleContainer> >("truthParticleLink")) return truthMu; + ElementLink<xAOD::TruthParticleContainer> link = mu.auxdata<ElementLink<xAOD::TruthParticleContainer> >("truthParticleLink"); + if(!link.isValid()) return truthMu; + truthMu = (*link); return truthMu; } @@ -255,17 +256,21 @@ TLorentzVector MuonResonancePlots::getTrackTLV(const xAOD::Muon& mu, int type){ TLorentzVector v; const xAOD::TrackParticle *cb_ = mu.trackParticle(xAOD::Muon::CombinedTrackParticle); const xAOD::TrackParticle *id_ = mu.trackParticle(xAOD::Muon::InnerDetectorTrackParticle); - const xAOD::TrackParticle* me_ = mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle); - if(!cb_ || !id_ || !me_) return v; + const xAOD::TrackParticle *me_ = mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle); + if(type>-1 && (!cb_ || !id_ || !me_)) return v; + + if(id_ && me_) { + float pt_id = id_->pt(); + float pt_me = me_->pt(); + if(mu.isAvailable< float >("InnerDetectorPt")) pt_id = mu.auxdata< float >("InnerDetectorPt"); + if(mu.isAvailable< float >("MuonSpectrometerPt")) pt_me = mu.auxdata< float >("MuonSpectrometerPt"); - float pt_id = id_->pt(); - float pt_me = me_->pt(); - if(mu.isAvailable< float >("InnerDetectorPt")) pt_id = mu.auxdata< float >("InnerDetectorPt"); - if(mu.isAvailable< float >("MuonSpectrometerPt")) pt_me = mu.auxdata< float >("MuonSpectrometerPt"); + if(type==1) v.SetPtEtaPhiM( pt_id, id_->eta(), id_->phi(), id_->m() ); + if(type==2) v.SetPtEtaPhiM( pt_me, me_->eta(), me_->phi(), me_->m() ); + } - if(type==0) v.SetPtEtaPhiM(mu.pt(), cb_->eta(), cb_->phi(), cb_->m()); - if(type==1) v.SetPtEtaPhiM(pt_id, cb_->eta(), cb_->phi(), cb_->m()); - if(type==2) v.SetPtEtaPhiM(pt_me, cb_->eta(), cb_->phi(), cb_->m()); + if(type==-1) v.SetPtEtaPhiM( mu.pt(), mu.eta(), mu.phi(), mu.m() ); + if(type==0) v.SetPtEtaPhiM( cb_->pt(), cb_->eta(), cb_->phi(), cb_->m() ); return v; } @@ -319,15 +324,16 @@ float MuonResonancePlots::deltaPt(TLorentzVector v1, TLorentzVector v2){ // function to return Chi² / DoF float MuonResonancePlots::getChiSquared(const xAOD::Muon& mu, int type){ - + const xAOD::TrackParticle *cb_ = mu.trackParticle(xAOD::Muon::CombinedTrackParticle); const xAOD::TrackParticle *id_ = mu.trackParticle(xAOD::Muon::InnerDetectorTrackParticle); const xAOD::TrackParticle* me_ = mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle); - if(!cb_ || !id_ || !me_) return 0; + if(type>-1 && (!cb_ || !id_ || !me_)) return 0; - if(type==0) return cb_->chiSquared()/cb_->numberDoF(); - if(type==1) return id_->chiSquared()/id_->numberDoF(); - if(type==2) return me_->chiSquared()/id_->numberDoF(); + if(type==-1 && mu.primaryTrackParticle()) return mu.primaryTrackParticle()->chiSquared()/mu.primaryTrackParticle()->numberDoF(); + if(type==0) return cb_->chiSquared()/cb_->numberDoF(); + if(type==1) return id_->chiSquared()/id_->numberDoF(); + if(type==2) return me_->chiSquared()/id_->numberDoF(); else return 0; } diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPCutFlowBase.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPCutFlowBase.cxx index 547745678fd1760858cea2f8717b0316f3f598d1..d79b072d04a2cc414826542b05a5c435fbf463ab 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPCutFlowBase.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPCutFlowBase.cxx @@ -15,6 +15,7 @@ MuonTPCutFlowBase::MuonTPCutFlowBase(PlotBase* pParent, std::string sDir) : PlotBase(pParent, sDir) {} + void MuonTPCutFlowBase::fill(std::string bin , double w){ auto tofill = m_hist_for_binlabel.find(bin); if (tofill != m_hist_for_binlabel.end()){ @@ -38,4 +39,4 @@ TH1* MuonTPCutFlowBase::AddCutFlow (std::string name, std::vector<std::string> s m_hist_for_binlabel[stage].push_back(out); } return out; -} \ No newline at end of file +} diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPEfficiencyPlotBase.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPEfficiencyPlotBase.cxx index 9acfd42e002c1a2217b6c863915814830c037260..52215bbd37265940508053e8176c9852abbd2542 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPEfficiencyPlotBase.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPEfficiencyPlotBase.cxx @@ -14,69 +14,71 @@ #include "TEfficiency.h" MuonTPEfficiencyPlotBase::MuonTPEfficiencyPlotBase(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF) - : PlotBase(pParent, sDir), - m_isMatched(isMatched), - m_apply_SF(ApplySF), - m_doAsymmErrors (false) - {} -void MuonTPEfficiencyPlotBase::fill(Probe& ){ +: PlotBase(pParent, sDir), +m_isMatched(isMatched), +m_apply_SF(ApplySF), +m_doAsymmErrors (false) +{} +void MuonTPEfficiencyPlotBase::fill(Probe& ){ } void MuonTPEfficiencyPlotBase::EffiDivide(MuonTPEfficiencyPlotBase* trials, MuonTPEfficiencyPlotBase* matches){ - // default: if not defined by the user try a generic approach that should always work - - std::vector<HistData> hd_trials = trials->retrieveBookedHistograms(); - std::vector<HistData> hd_matches = matches->retrieveBookedHistograms(); - std::vector<HistData> hd_effi = this->retrieveBookedHistograms(); + // default: if not defined by the user try a generic approach that should always work + + std::vector<HistData> hd_trials = trials->retrieveBookedHistograms(); + std::vector<HistData> hd_matches = matches->retrieveBookedHistograms(); + std::vector<HistData> hd_effi = this->retrieveBookedHistograms(); std::vector<std::pair <TGraph*, std::string > > hd_effi_graphs = this->retrieveBookedGraphs(); - - for (size_t i = 0; i < hd_effi.size();++i){ - EffiDivide(hd_trials[i].first, hd_matches[i].first,hd_effi[i].first); - if (m_doAsymmErrors) EffiDivide(hd_trials[i].first, hd_matches[i].first,dynamic_cast <TGraphAsymmErrors*>(hd_effi_graphs[i].first)); + + for (size_t i = 0; i < hd_effi.size();++i){ + EffiDivide(hd_trials[i].first, hd_matches[i].first,hd_effi[i].first); + if (m_doAsymmErrors && hd_effi_graphs.size()>i && hd_effi_graphs[i].first){ + TGraphAsymmErrors* hd_effi_graph = dynamic_cast <TGraphAsymmErrors*>(hd_effi_graphs[i].first); + if (hd_effi_graph) EffiDivide(hd_trials[i].first, hd_matches[i].first,hd_effi_graph); } + } } void MuonTPEfficiencyPlotBase::EffiDivide(TH1* trials, TH1* matches, TH1* eff){ - - TH1D* trials_1d = dynamic_cast<TH1D*>(trials); - TH2D* trials_2d = dynamic_cast<TH2D*>(trials); - if (trials_1d){ - for (int ibin = 0; ibin < trials_1d->GetNbinsX()+2;++ibin){ - EffiDivide(ibin, trials,matches,eff); - } + + TH1D* trials_1d = dynamic_cast<TH1D*>(trials); + TH2D* trials_2d = dynamic_cast<TH2D*>(trials); + if (trials_1d){ + for (int ibin = 0; ibin < trials_1d->GetNbinsX()+2;++ibin){ + EffiDivide(ibin, trials,matches,eff); } - else if (trials_2d){ - for (int ibin = 0; ibin < (trials_2d->GetNbinsX()+2)*(trials_2d->GetNbinsY()+2);++ibin){ - EffiDivide(ibin, trials,matches,eff); - } + } + else if (trials_2d){ + for (int ibin = 0; ibin < (trials_2d->GetNbinsX()+2)*(trials_2d->GetNbinsY()+2);++ibin){ + EffiDivide(ibin, trials,matches,eff); } + } } + void MuonTPEfficiencyPlotBase::EffiDivide (TH1* trials, TH1* matches, TGraphAsymmErrors* effi) { TH1D* trials_1d = dynamic_cast<TH1D*>(trials); TH1D* matches_1d = dynamic_cast<TH1D*>(matches); if (!trials_1d) return; effi->Divide(matches_1d, trials_1d, "cp"); - - } - void MuonTPEfficiencyPlotBase::EffiDivide(int ibin, TH1* trials, TH1* matches, TH1* eff){ - - double den = trials->GetBinContent(ibin); - double dden = trials->GetBinError(ibin); - - double num = matches->GetBinContent(ibin); - double dnum = matches->GetBinError(ibin); - - effResult res = CalcEff (den, num, dden, dnum); - - eff->SetBinContent(ibin,res.first); + + double den = trials->GetBinContent(ibin); + double dden = trials->GetBinError(ibin); + + double num = matches->GetBinContent(ibin); + double dnum = matches->GetBinError(ibin); + + effResult res = CalcEff (den, num, dden, dnum); + + eff->SetBinContent(ibin,res.first); // Symmetrize the errors for the TH1* case eff->SetBinError(ibin,(res.second.first + res.second.second)/2.); } + MuonTPEfficiencyPlotBase::effResult MuonTPEfficiencyPlotBase::CalcEff (double den, double num, double , double ) { static double gamma = 1.0 - 0.683; @@ -88,16 +90,16 @@ MuonTPEfficiencyPlotBase::effResult MuonTPEfficiencyPlotBase::CalcEff (double de double dEff_down = 1; if (den > 0) { - Eff = num / den; - - if ( num > 0 && den-num > 0) { - - double F_lo = ROOT::Math::fdistribution_quantile(alfa_lo, 2*num, 2*(den-num+1.)); - double F_hi = ROOT::Math::fdistribution_quantile(1. - alfa_hi, 2*(num+1.), 2*(den-num)); - - dEff_down = Eff - (num * F_lo)/(den - num + 1. + num * F_lo); - dEff_up = ((num + 1.) * F_hi)/((den - num) + (num+1.)*F_hi) - Eff; - } + Eff = num / den; + + if ( num > 0 && den-num > 0) { + + double F_lo = ROOT::Math::fdistribution_quantile(alfa_lo, 2*num, 2*(den-num+1.)); + double F_hi = ROOT::Math::fdistribution_quantile(1. - alfa_hi, 2*(num+1.), 2*(den-num)); + + dEff_down = Eff - (num * F_lo)/(den - num + 1. + num * F_lo); + dEff_up = ((num + 1.) * F_hi)/((den - num) + (num+1.)*F_hi) - Eff; + } } return std::make_pair (Eff, std::make_pair (dEff_up, dEff_down)); @@ -152,7 +154,6 @@ TGraphAsymmErrors* MuonTPEfficiencyPlotBase::BookGraphAsymmErrors(const std::str std::string prefix = ""; if (prependDir) { prefix = m_sDirectory; - std::replace( prefix.begin(), prefix.end(), '/', '_'); } TGraphAsymmErrors* graph = new TGraphAsymmErrors(); graph->SetName((prefix + name2).c_str()); diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPEfficiencyPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPEfficiencyPlots.cxx index 4ad3fe1d24f818584e6179538134d40df4d5458f..ce16fabb4551e86dcf5e2e30d38045389760fd94 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPEfficiencyPlots.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTPEfficiencyPlots.cxx @@ -11,8 +11,8 @@ MuonTPEfficiencyPlots::MuonTPEfficiencyPlots(PlotBase* pParent, std::string sDir m_isMatched(isMatched), m_probeTrkKinePlots(this, "/", "Probe"), m_probeTrkImpactPlots(this, "/"), - m_probeTrkRecoInfoPlots(this, "/"), - m_probeMuonRecoInfoPlots(this, "/"), + m_probeTrkRecoInfoPlots(this, "/Trk_"), + m_probeMuonRecoInfoPlots(this, "/Mu_"), m_probeMuonIsolationPlots(this, "/") {} diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTrigTPEfficiencyPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTrigTPEfficiencyPlots.cxx index 913041df51cb01beb116416d978ce2d3d333c1e3..0aba4ddb2de922d54ec738ee2434ac0f5583a5cd 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTrigTPEfficiencyPlots.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonTrigTPEfficiencyPlots.cxx @@ -27,14 +27,15 @@ MuonTrigTPEfficiencyPlots::MuonTrigTPEfficiencyPlots(PlotBase* pParent, std::str : MuonTPEfficiencyPlotBase (pParent, sDir, isMatched, ApplySF), m_isMatched(isMatched) { - pt = Book1D( "_pt" ," pt; Pt, GeV; Entries / 1 GeV ",50,0.0,100.); - eta = Book1D("_eta" ," eta; #eta; Entries ",50,-2.5,2.5); - phi = Book1D("_phi" ," phi; #phi; Entries ",64,-TMath::Pi(),TMath::Pi()); - eta_phi = Book2D("_eta_phi" , "eta vs phi",50,-2.5,2.5,32,-TMath::Pi(),TMath::Pi()); - - dRL1 = Book1D("_dRL1" ," dRL1; dR; Entries ",100,0,0.3); - dRHLT = Book1D("_dRHLT" ," dRHLT; dR; Entries ",100,0,0.001); - mll = Book1D("_mll" ," mll; GeV; Entries / 1 GeV ",100,50.0,130.); + + double ptbins[] = {0.,5.,10.,15.,20.,25.,30.,35.,40.,45.,50.,55.,60.,65.,70.,75,80.,85,90.,95,100.,120.,140.,160.,180.,200.}; + int nptbins = sizeof (ptbins) / sizeof (double) - 1; + TH1D ptdummy ("ptdummy","dummy",nptbins,ptbins) ; + pt = Book1D("pt" ,&ptdummy, " Large Pt; Muon Transverse Momentum [GeV];Entries / 1 GeV"); + eta = Book1D("eta" ," eta; #eta; Entries ",50,-2.5,2.5); + phi = Book1D("phi" ," phi; #phi; Entries ",64,-TMath::Pi(),TMath::Pi()); + eta_phi = Book2D("eta_phi" , "eta vs phi",50,-2.5,2.5,32,-TMath::Pi(),TMath::Pi()); + } @@ -104,12 +105,15 @@ void MuonTrigTPEfficiencyPlots::fill(Probe& probe) if ( probe.pt()/1000. > TriggerThreshold*1.05) { eta->Fill(probe.eta(),sfweight); - phi->Fill(probe.phi(),sfweight); + if(CurrentTrigger=="HLT_mu60_0eta105_msonly") + { + if(fabs(probe.eta())<=1.05) + phi->Fill(probe.phi(),sfweight); + } + else + { + phi->Fill(probe.phi(),sfweight); + } eta_phi->Fill(probe.eta(),probe.phi()); - - dRL1->Fill(probe.dRL1,sfweight); - dRHLT->Fill(probe.dRHLT,sfweight); - TLorentzVector z = probe.probeTrack().p4() + probe.tagTrack().p4(); - mll->Fill(z.M() / 1000.,sfweight); } } diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonWCandidatePlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonWCandidatePlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b5e73ab03a6ad4d642547131b646f34ae3750091 --- /dev/null +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/MuonWCandidatePlots.cxx @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonPerformanceHistUtils/MuonWCandidatePlots.h" +#include "xAODTracking/TrackingPrimitives.h" +#include <TLorentzVector.h> + +MuonWCandidatePlots::MuonWCandidatePlots(PlotBase *pParent, std::string sDir):PlotBase(pParent, sDir) + , me_t(NULL) + , me_x(NULL) + , me_y(NULL) + , mu_pt(NULL) + , mu_eta(NULL) + , mu_phi(NULL) + , w_pt(NULL) + , w_phi(NULL) + , w_mt(NULL) +{} + +void MuonWCandidatePlots::initializePlots() +{ + me_t = Book1D("me_T","ME_T;ME_T [GeV];Entries",200,0.,200.); + me_x = Book1D("me_X","ME_X;ME_X [GeV];Entries",200,0.,200.); + me_y = Book1D("me_Y","ME_Y;ME_Y [GeV];Entries",200,0.,200.); + + mu_pt = Book1D("mu_pt","mu_pt;p_{T,#mu} [GeV];Entries",200,0.,200.); + mu_eta = Book1D("mu_eta","mu_eta;#eta_{#mu};Entries",64,-3.2,3.2); + mu_phi = Book1D("mu_phi","mu_phi;#phi_{#mu};Entries",60,-3.0,3.0); + + w_pt = Book1D("w_pt","w_pt;p_{T,W} [GeV];Entries",200,0.,200.); + w_phi = Book1D("w_phi","w_phi;#phi_{W};Entries",64,-3.2,3.2); + w_mt = Book1D("w_mt","w_mt;m_{T,W} [GeV];Entries",200,0.,200.); +} + + +void MuonWCandidatePlots::fill(const xAOD::Muon& mu, const xAOD::MissingET& met) +{ + me_t->Fill(met.met()/1000.); + me_x->Fill(met.mpx()/1000.); + me_y->Fill(met.mpy()/1000.); + + mu_pt->Fill(mu.pt()/1000.); + mu_eta->Fill(mu.eta()); + mu_phi->Fill(mu.phi()); + + TLorentzVector metP4; + metP4.SetPxPyPzE(met.mpx(), met.mpy(), 0.0, met.met()); + TLorentzVector muP4 = mu.p4(); + TLorentzVector mutP4; + mutP4.SetPxPyPzE(muP4.Px(), muP4.Py(), 0.0, muP4.Pt()); + TLorentzVector Wcand = mutP4+metP4; + + w_pt->Fill(Wcand.Pt()/1000.); + w_mt->Fill(Wcand.M()/1000.); + w_phi->Fill(Wcand.Phi()); +} + + diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/Probe.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/Probe.cxx index 1639d9eace00cf920916b1106fa973272972d9a2..c8e0edf00ad9f1bd56293e8d41482f8c116f2fbd 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/Probe.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/Probe.cxx @@ -6,7 +6,27 @@ // constructor Probe::Probe(const xAOD::IParticle& tagTrack, const xAOD::IParticle& probeTrack) : - m_isMatched(false), m_tagTrack(tagTrack), m_probeTrack(probeTrack), m_sf_weight(1) + dRL1(-1), + dRHLT(-1), + m_isMatched(false), + m_tagTrack(tagTrack), + m_probeTrack(probeTrack), + m_sf_weight(1), + m_tagPassTrigger(0), + m_HasSomeTrigger(false), + m_HasSomeTrigger_HLT(false) +{} + +Probe::Probe(const xAOD::IParticle& tagTrack, const xAOD::IParticle& probeTrack, int tagPassTrigger) : + dRL1(-1), + dRHLT(-1), + m_isMatched(false), + m_tagTrack(tagTrack), + m_probeTrack(probeTrack), + m_sf_weight(1), + m_tagPassTrigger(tagPassTrigger), + m_HasSomeTrigger(false), + m_HasSomeTrigger_HLT(false) {} // denstructor diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuBasicTPEfficiencyPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuBasicTPEfficiencyPlots.cxx index 9af3918ec9ce899701889a937567421e64a4a933..6a392be5ced805972d5aae3af684e24c38084b20 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuBasicTPEfficiencyPlots.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuBasicTPEfficiencyPlots.cxx @@ -15,26 +15,28 @@ ZmumuBasicTPEfficiencyPlots::ZmumuBasicTPEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF) : MuonTPEfficiencyPlotBase (pParent, sDir, isMatched, ApplySF), - m_isMatched(isMatched) { - - double ptbins[] = {10.,15.,20.,25.,30.,35.,40.,45.,50.,60.,70.,80.,90.,100.,120.}; - int nptbins = sizeof (ptbins) / sizeof (double) - 1; - TH1D ptdummy ("ptdummy","dummy",nptbins,ptbins) ; - pt = Book1D("pt" ,&ptdummy, " pt; Transverse Momentum [GeV];Entries / 1 GeV"); - eta = Book1D("eta" ," eta; #eta; Entries ",50,-2.5,2.5); - phi = Book1D("phi" ," phi; #phi; Entries ",32,-TMath::Pi(),TMath::Pi()); - integrated = Book1D("integrated" ," integrated; ; Entries ",1,0.5,1.5); + m_isMatched(isMatched) { +} +void ZmumuBasicTPEfficiencyPlots::initializePlots() +{ + double ptbins[] = {10.,15.,20.,25.,30.,35.,40.,45.,50.,60.,70.,80.,90.,100.,120.}; + int nptbins = sizeof (ptbins) / sizeof (double) - 1; + TH1D ptdummy ("ptdummy","dummy",nptbins,ptbins) ; + pt = Book1D("pt" ,&ptdummy, " pt; Transverse Momentum [GeV];Entries / 1 GeV"); + eta = Book1D("eta" ," eta; #eta; Entries ",50,-2.5,2.5); + phi = Book1D("phi" ," phi; #phi; Entries ",32,-TMath::Pi(),TMath::Pi()); + integrated = Book1D("integrated" ," integrated; ; Entries ",1,0.5,1.5); } void ZmumuBasicTPEfficiencyPlots::fill(Probe& probe) { - if(m_isMatched && !probe.isMatched()) return; - float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); - pt->Fill(probe.pt() / 1000.,sfweight); - eta->Fill(probe.eta() ,sfweight); - phi->Fill(probe.phi() ,sfweight); - integrated->Fill(1,sfweight); + if(m_isMatched && !probe.isMatched()) return; + float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); + pt->Fill(probe.pt() / 1000.,sfweight); + eta->Fill(probe.eta() ,sfweight); + phi->Fill(probe.phi() ,sfweight); + integrated->Fill(1,sfweight); } diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuDetRegionEfficiencyPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuDetRegionEfficiencyPlots.cxx index 8ac4c3eba010fea396cd7532a92e09c7e3bb66f5..4bb32969f6782099145bc7b67eb81b2bea1ff533 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuDetRegionEfficiencyPlots.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuDetRegionEfficiencyPlots.cxx @@ -16,33 +16,33 @@ ZmumuDetRegionEfficiencyPlots::ZmumuDetRegionEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF) : MuonTPEfficiencyPlotBase (pParent, sDir, isMatched, ApplySF), - m_isMatched(isMatched) { - - detregions = Book1D("DetRegions" ," DetRegions; Detector region; Entries ",(int)(EtaPhiBinning::nBINREGIONS),(int)(EtaPhiBinning::binUNKNOWN)-0.5, (int)(EtaPhiBinning::nBINREGIONS)-0.5); - detregions_A = Book1D("DetRegions_Aside" ," DetRegions; Detector region; Entries ",(int)(EtaPhiBinning::nBINREGIONS),(int)(EtaPhiBinning::binUNKNOWN)-0.5, (int)(EtaPhiBinning::nBINREGIONS)-0.5); - detregions_C = Book1D("DetRegions_Cside" ,"DetRegions; Detector region; Entries ",(int)(EtaPhiBinning::nBINREGIONS),(int)(EtaPhiBinning::binUNKNOWN)-0.5, (int)(EtaPhiBinning::nBINREGIONS)-0.5); - - for (int k = 1; k < detregions->GetNbinsX()+1;++k){ - std::string label = m_etaphi.GetRegionLabel(detregions->GetXaxis()->GetBinCenter(k)); - detregions->GetXaxis()->SetBinLabel(k, label.c_str()); - detregions_A->GetXaxis()->SetBinLabel(k, label.c_str()); - detregions_C->GetXaxis()->SetBinLabel(k, label.c_str()); - } - + m_isMatched(isMatched) {} + +void ZmumuDetRegionEfficiencyPlots::initializePlots() +{ + detregions = Book1D("DetRegions" ," DetRegions; Detector region; Entries ",(int)(EtaPhiBinning::nBINREGIONS),(int)(EtaPhiBinning::binUNKNOWN)-0.5, (int)(EtaPhiBinning::nBINREGIONS)-0.5); + detregions_A = Book1D("DetRegions_Aside" ," DetRegions; Detector region; Entries ",(int)(EtaPhiBinning::nBINREGIONS),(int)(EtaPhiBinning::binUNKNOWN)-0.5, (int)(EtaPhiBinning::nBINREGIONS)-0.5); + detregions_C = Book1D("DetRegions_Cside" ,"DetRegions; Detector region; Entries ",(int)(EtaPhiBinning::nBINREGIONS),(int)(EtaPhiBinning::binUNKNOWN)-0.5, (int)(EtaPhiBinning::nBINREGIONS)-0.5); + + for (int k = 1; k < detregions->GetNbinsX()+1;++k){ + std::string label = m_etaphi.GetRegionLabel(detregions->GetXaxis()->GetBinCenter(k)); + detregions->GetXaxis()->SetBinLabel(k, label.c_str()); + detregions_A->GetXaxis()->SetBinLabel(k, label.c_str()); + detregions_C->GetXaxis()->SetBinLabel(k, label.c_str()); + } } - void ZmumuDetRegionEfficiencyPlots::fill(Probe& probe){ - if(m_isMatched && !probe.isMatched()) return; - float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); - - TLorentzVector lv = probe.probeTrack().p4(); - - detregions->Fill(m_etaphi.symmetricBin(lv), sfweight); - if (fabs(lv.Eta()) > 0){ - detregions_A->Fill(m_etaphi.symmetricBin(lv), sfweight); - } - else { - detregions_C->Fill(m_etaphi.symmetricBin(lv), sfweight); - } + if(m_isMatched && !probe.isMatched()) return; + float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); + + TLorentzVector lv = probe.probeTrack().p4(); + + detregions->Fill(m_etaphi.symmetricBin(lv), sfweight); + if (fabs(lv.Eta()) > 0){ + detregions_A->Fill(m_etaphi.symmetricBin(lv), sfweight); + } + else { + detregions_C->Fill(m_etaphi.symmetricBin(lv), sfweight); + } } diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuFineEtaPhiEfficiencyPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuFineEtaPhiEfficiencyPlots.cxx index 1b86c8c6a53e0da846295b272aa98bde2a6c8e10..9bfaebc5f82be987432ed433bf004f401fa489f3 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuFineEtaPhiEfficiencyPlots.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuFineEtaPhiEfficiencyPlots.cxx @@ -16,42 +16,42 @@ ZmumuFineEtaPhiEfficiencyPlots::ZmumuFineEtaPhiEfficiencyPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF) : MuonTPEfficiencyPlotBase (pParent, sDir, isMatched, ApplySF), - m_isMatched(isMatched) { - - fineEtaPhi = Book1D("fineEtaPhi" ," fineEtaPhi; fine (#eta, #phi) bin; Entries ",m_fepb.nbins(),m_fepb.firstbin()-0.5, m_fepb.lastbin()+0.5); - fineEtaPhi_posq = Book1D("fineEtaPhi_posq" ," fineEtaPhi_posq; fine (#eta, #phi) bin; Entries ",m_fepb.nbins(),m_fepb.firstbin()-0.5, m_fepb.lastbin()+0.5); - fineEtaPhi_negq = Book1D("fineEtaPhi_negq" ," fineEtaPhi_negq; fine (#eta, #phi) bin; Entries ",m_fepb.nbins(),m_fepb.firstbin()-0.5, m_fepb.lastbin()+0.5); + m_isMatched(isMatched) {} +void ZmumuFineEtaPhiEfficiencyPlots::initializePlots() +{ + fineEtaPhi = Book1D("fineEtaPhi" ," fineEtaPhi; fine (#eta, #phi) bin; Entries ",m_fepb.nbins(),m_fepb.firstbin()-0.5, m_fepb.lastbin()+0.5); + fineEtaPhi_posq = Book1D("fineEtaPhi_posq" ," fineEtaPhi_posq; fine (#eta, #phi) bin; Entries ",m_fepb.nbins(),m_fepb.firstbin()-0.5, m_fepb.lastbin()+0.5); + fineEtaPhi_negq = Book1D("fineEtaPhi_negq" ," fineEtaPhi_negq; fine (#eta, #phi) bin; Entries ",m_fepb.nbins(),m_fepb.firstbin()-0.5, m_fepb.lastbin()+0.5); } - void ZmumuFineEtaPhiEfficiencyPlots::fill(Probe& probe) { - if(m_isMatched && !probe.isMatched()) return; - float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); - // case 1: ID track - const xAOD::TrackParticle* trk = dynamic_cast<const xAOD::TrackParticle*>(&(probe.probeTrack())); + if(m_isMatched && !probe.isMatched()) return; + float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); + // case 1: ID track + const xAOD::TrackParticle* trk = dynamic_cast<const xAOD::TrackParticle*>(&(probe.probeTrack())); - // in case that didn't work, try a muon! - if (!trk) { - const xAOD::Muon* mu = dynamic_cast<const xAOD::Muon*> (&(probe.probeTrack())); - if (mu && mu->primaryTrackParticle()) trk = mu->primaryTrackParticle(); - if (!trk && mu && *(mu->inDetTrackParticleLink())) trk = *(mu->inDetTrackParticleLink()); - } - if (trk) { - if(trk->charge() > 0) fineEtaPhi_posq->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); - if(trk->charge() < 0) fineEtaPhi_negq->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); - } - else { - // truth probes: rely on the sign of the pdg ID - const xAOD::TruthParticle* truthtrk = dynamic_cast<const xAOD::TruthParticle*>(&(probe.probeTrack())); - if (truthtrk){ - if (truthtrk->charge() > 0) fineEtaPhi_posq->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); - if (truthtrk->charge() < 0) fineEtaPhi_negq->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); - } + // in case that didn't work, try a muon! + if (!trk) { + const xAOD::Muon* mu = dynamic_cast<const xAOD::Muon*> (&(probe.probeTrack())); + if (mu && mu->primaryTrackParticle()) trk = mu->primaryTrackParticle(); + if (!trk && mu && *(mu->inDetTrackParticleLink())) trk = *(mu->inDetTrackParticleLink()); + } + if (trk) { + if(trk->charge() > 0) fineEtaPhi_posq->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); + if(trk->charge() < 0) fineEtaPhi_negq->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); + } + else { + // truth probes: rely on the sign of the pdg ID + const xAOD::TruthParticle* truthtrk = dynamic_cast<const xAOD::TruthParticle*>(&(probe.probeTrack())); + if (truthtrk){ + if (truthtrk->charge() > 0) fineEtaPhi_posq->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); + if (truthtrk->charge() < 0) fineEtaPhi_negq->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); } + } - fineEtaPhi->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); + fineEtaPhi->Fill(m_fepb.bin(probe.probeTrack().p4()),sfweight); } diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuTagProbeDileptonPlots.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuTagProbeDileptonPlots.cxx index 26ba827373e5c61d7add41d8135c5118fa9c748a..38da4e96ae28b4a3ff60cafbe8fad9d3376990d3 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuTagProbeDileptonPlots.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/Root/ZmumuTagProbeDileptonPlots.cxx @@ -2,28 +2,28 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ - // ZmumuBasicTPEfficiencyPlots.cxx +// ZmumuBasicTPEfficiencyPlots.cxx #include "MuonPerformanceHistUtils/ZmumuTagProbeDileptonPlots.h" - ZmumuTagProbeDileptonPlots::ZmumuTagProbeDileptonPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF) +ZmumuTagProbeDileptonPlots::ZmumuTagProbeDileptonPlots(PlotBase* pParent, std::string sDir, bool isMatched, bool ApplySF) : MuonTPEfficiencyPlotBase (pParent, sDir, isMatched, ApplySF), - m_isMatched(isMatched) { - - m_ll = Book1D("m_ll","mll; m_{ll} [GeV]; Entries",80,71000.,111000.); - opening_angle = Book1D("opening_angle","opening_angle; Dilepton opening angle; Entries",40,0.0,TMath::Pi()); - z_pt = Book1D("z_pt","z_pt; Z boson p_{T} [GeV] ; Entries",100,0.0,400000.); + m_isMatched(isMatched) {} +void ZmumuTagProbeDileptonPlots::initializePlots() +{ + m_ll = Book1D("m_ll","mll; m_{ll} [GeV]; Entries",80,71000.,111000.); + opening_angle = Book1D("opening_angle","opening_angle; Dilepton opening angle; Entries",40,0.0,TMath::Pi()); + z_pt = Book1D("z_pt","z_pt; Z boson p_{T} [GeV] ; Entries",100,0.0,400000.); } - void ZmumuTagProbeDileptonPlots::fill(Probe& probe) { - if(m_isMatched && !probe.isMatched()) return; - float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); - TLorentzVector z = probe.probeTrack().p4() + probe.tagTrack().p4(); - m_ll->Fill(z.M(),sfweight ); - z_pt->Fill(z.Pt(),sfweight); - opening_angle->Fill(fabs(probe.probeTrack().p4().Angle(probe.tagTrack().p4().Vect())),sfweight); + if(m_isMatched && !probe.isMatched()) return; + float sfweight = (m_isMatched && m_apply_SF ? probe.sfweight() : 1.); + TLorentzVector z = probe.probeTrack().p4() + probe.tagTrack().p4(); + m_ll->Fill(z.M(),sfweight ); + z_pt->Fill(z.Pt(),sfweight); + opening_angle->Fill(fabs(probe.probeTrack().p4().Angle(probe.tagTrack().p4().Vect())),sfweight); } diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/cmt/Makefile.RootCore b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/cmt/Makefile.RootCore index 6480aceea485c168ac69063a766e122f2fe0daf5..fb0fde5435ef1ea6978d5c6b83ef5a2e717a7b23 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/cmt/Makefile.RootCore +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/cmt/Makefile.RootCore @@ -28,7 +28,7 @@ PACKAGE_BINFLAGS = PACKAGE_LIBFLAGS = # the list of packages we depend on: -PACKAGE_DEP = xAODMuon xAODTracking xAODTruth TrkValHistUtils xAODTrigger xAODTrigMuon MuonHistUtils MuonEfficiencyCorrections +PACKAGE_DEP = xAODMuon xAODTracking xAODTruth TrkValHistUtils xAODTrigger xAODTrigMuon MuonHistUtils MuonEfficiencyCorrections xAODMissingET # the list of packages we use if present, but that we can work without : PACKAGE_TRYDEP = diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/cmt/requirements b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/cmt/requirements index 026ccc6367313bdf5e9fd016730c3c20dabb8f6f..f87dd68dd8f114ff61da8d4311a9487676378c20 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/cmt/requirements +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonPerformanceHistUtils/cmt/requirements @@ -4,7 +4,7 @@ author Massimiliano Bellomo public use AtlasPolicy AtlasPolicy-* -#use AthenaMonitoring AthenaMonitoring-* Control +#use AthenaMonitoring AthenaMonitoring-* Control use GaudiInterface GaudiInterface-* External use AsgTools AsgTools-* Control/AthToolSupport use xAODBase xAODBase-* Event/xAOD @@ -14,6 +14,7 @@ use MuonEfficiencyCorrections MuonEfficiencyCorrections-* PhysicsAnalysis/MuonID use xAODMuon xAODMuon-* Event/xAOD use xAODTruth xAODTruth-* Event/xAOD use AtlasROOT AtlasROOT-* External +use xAODMissingET xAODMissingET-* Event/xAOD private