ATLAS Offline Software
Loading...
Searching...
No Matches
MomentumTruthPullPlots.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <utility>
6
9#ifndef XAOD_ANALYSIS
11#endif // not XAOD_ANALYSIS
12
13namespace Muon{
14
15
16MomentumTruthPullPlots::MomentumTruthPullPlots(PlotBase* pParent, const std::string& sDir, std::string sType):
17 PlotBase(pParent, sDir),
18 m_sType(std::move(sType))
19{}
20
22
24{
25 dp_CB_truthIP = Book1D("dp_CB_truthIP_"+m_sType,m_sType+" pCB-ptruthIP;#Delta p;Entries",200,-10,10);
26 dp_ME_truthIP = Book1D("dp_ME_truthIP_"+m_sType,m_sType+" pME-ptruthIP;#Delta p;Entries",200,-10,10);
27 dp_ME_truthIP_MS_truthMS = Book1D("dp_ME_truthIP_MS_truthMS_"+m_sType,m_sType+" (pME-ptruthIP) - (pMS-ptruthMS);#Delta p;Entries",200,-10,10);
28 dp_eloss = Book1D("dp_eloss_"+m_sType,m_sType+" dp_eloss;#Delta p;Entries",200,-10,10);
29
30 Double_t ptBins[] = {5, 10, 25, 60, 100, 200, 1000};
31 Double_t etaBins[] = {-2.7, -2.5, -1.7, -1.05, -0.1, 0.1, 1.05, 1.7, 2.5, 2.7};
32 //Double_t phiBins[] = {-3.15, -2.4, -1.6, -0.8, 0, 0.8, 1.6, 2.4, 3.15};
33
34 const unsigned int nptBins = sizeof(ptBins)/sizeof(ptBins[0])-1;
35 const unsigned int netaBins = sizeof(etaBins)/sizeof(etaBins[0])-1;
36
37 dp_CB_truthIP_vs_pt = Book2D("dp_CB_truthIP_vs_pt_"+m_sType,m_sType+" pCB-ptruthIP vs pt;pt;#Delta p",nptBins,ptBins,100,-10.,10.);
38 dp_ME_truthIP_vs_pt = Book2D("dp_ME_truthIP_vs_pt_"+m_sType,m_sType+" pME-ptruthIP vs pt;pt;#Delta p",nptBins,ptBins,100,-10.,10.);
39 dp_ME_truthIP_MS_truthMS_vs_pt = Book2D("dp_ME_truthIP_MS_truthMS_vs_pt_"+m_sType,m_sType+" (pME-ptruthIP) - (pMS-ptruthMS) vs pt;pt;#Delta p",nptBins,ptBins,200,-10.,10.);
40 dp_eloss_vs_pt = Book2D("dp_eloss_vs_pt_"+m_sType,m_sType+" dp_eloss vs pt;pt [GeV]; #Delta p",nptBins,ptBins,100,-10.,10.);
41
42 dp_CB_truthIP_vs_eta = Book2D("dp_CB_truthIP_vs_eta_"+m_sType,m_sType+" pCB-ptruthIP vs eta;eta;#Delta p",netaBins,etaBins,100,-10.,10.);
43 dp_ME_truthIP_vs_eta = Book2D("dp_ME_truthIP_vs_eta_"+m_sType,m_sType+" pME-ptruthIP vs eta;eta;#Delta p",netaBins,etaBins,100,-10.,10.);
44 dp_ME_truthIP_MS_truthMS_vs_eta = Book2D("dp_ME_truthIP_MS_truthMS_vs_eta_"+m_sType,m_sType+" (pME-ptruthIP) - (pMS-ptruthMS) vs eta;eta;#Delta p",netaBins,etaBins,200,-10.,10.);
45 dp_eloss_vs_eta = Book2D("dp_eloss_vs_eta_"+m_sType,m_sType+" dp_eloss vs eta;eta; #Delta p",netaBins,etaBins,100,-10.,10.);
46
47}
48
49 void MomentumTruthPullPlots::fill(const xAOD::Muon& muon, const xAOD::TrackParticle* msTrk, const xAOD::TruthParticle& truthMu, float weight)
50{
51 if (!(muon.muonType()==xAOD::Muon::Combined || muon.muonType()==xAOD::Muon::SegmentTagged || muon.muonType()==xAOD::Muon::MuonStandAlone)) return;
52
53 const xAOD::TrackParticle* muPrimaryTrk = muon.trackParticle(xAOD::Muon::Primary);
54 if (!muPrimaryTrk) return;
55
56 const xAOD::TrackParticle* msExtrapTrk = muon.trackParticle(xAOD::Muon::TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle);
57 if (!msExtrapTrk) msExtrapTrk = muon.trackParticle(xAOD::Muon::MuonSpectrometerTrackParticle);
58
59 float eta = truthMu.eta();
60 float pt = 0.001*truthMu.pt();
61
62 float pTruth = truthMu.p4().P();
63 float pCB = muPrimaryTrk->p4().P();
64 float pME = 0;
65 if (msExtrapTrk) pME = msExtrapTrk->p4().P(); //muon extrapolated
66 float pMS = 0;
67 if (msTrk) pMS = msTrk->p4().P(); //at muon spectrometer entry//@@@
68
69 float eloss = 0;
70 if (muon.parameter(eloss,xAOD::Muon::MeasEnergyLoss)) {;}
71 float pTruthMS = 0; //p truth at MS entry
72 static const SG::ConstAccessor<float> entpxAcc ("MuonEntryLayer_px");
73 static const SG::ConstAccessor<float> entpyAcc ("MuonEntryLayer_py");
74 static const SG::ConstAccessor<float> entpzAcc ("MuonEntryLayer_pz");
75 if (entpxAcc.isAvailable(truthMu) &&
76 entpyAcc.isAvailable(truthMu) &&
77 entpzAcc.isAvailable(truthMu) ) {
78 Amg::Vector3D pvecTruthMS{entpxAcc(truthMu),
79 entpyAcc(truthMu),
80 entpzAcc(truthMu)};
81 pTruthMS = pvecTruthMS.mag();
82 }
83
84 if (muon.muonType()!=xAOD::Muon::SegmentTagged) {
85 if (pTruth) {
86 float dpCB = 0.001*(pCB-pTruth);
87 dp_CB_truthIP->Fill(dpCB,weight);
88 dp_CB_truthIP_vs_pt->Fill(pt,dpCB,weight);
89 dp_CB_truthIP_vs_eta->Fill(eta,dpCB,weight);
90 if (pME) {
91 float dpME = 0.001*(pME-pTruth);
92 dp_ME_truthIP->Fill(dpME,weight);
93 dp_ME_truthIP_vs_pt->Fill(pt,dpME,weight);
94 dp_ME_truthIP_vs_eta->Fill(eta,dpME,weight);
95 if (pMS && pTruthMS) {
96 float dpMS = 0.001*(pME - pMS - pTruth + pTruthMS);
97 dp_ME_truthIP_MS_truthMS->Fill(dpMS,weight);
98 dp_ME_truthIP_MS_truthMS_vs_pt->Fill(pt,dpMS,weight);
99 dp_ME_truthIP_MS_truthMS_vs_eta->Fill(eta,dpMS,weight);
100 }
101 }
102 }
103 }
104
105 //if (muon.muonType()==xAOD::Muon::Combined || muon.muonType()==xAOD::Muon::SegmentTagged || muon.muonType()==xAOD::Muon::MuonStandAlone) {
106 if (eloss>2000 && pTruthMS && pTruth) {
107 float dpEloss = 0.001*(pTruth - pTruthMS - eloss);
108 dp_eloss->Fill(dpEloss,weight);
109 dp_eloss_vs_pt->Fill(pt,dpEloss,weight);
110 dp_eloss_vs_eta->Fill(eta,dpEloss,weight);
111 }
112
113}
114
115
116
117} // closing namespace Muon
Scalar eta() const
pseudorapidity method
Helper class to provide constant type-safe access to aux data.
MomentumTruthPullPlots(PlotBase *pParent, const std::string &sDir, std::string sType)
void fill(const xAOD::Muon &muon, const xAOD::TrackParticle *muontpIP, const xAOD::TruthParticle &truthprt, float weight=1.0)
TH1D * Book1D(const std::string &name, const std::string &labels, int nBins, float start, float end, bool prependDir=true)
Book a TH1D histogram.
Definition PlotBase.cxx:94
PlotBase(PlotBase *parent, const std::string &sDir)
Definition PlotBase.cxx:29
TH2F * Book2D(const std::string &name, const std::string &labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, bool prependDir=true)
Book a TH2F histogram.
Definition PlotBase.cxx:123
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Eigen::Matrix< double, 3, 1 > Vector3D
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
STL namespace.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version: