Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
13 namespace Muon{
14 
15 
16 MomentumTruthPullPlots::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);
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
PlotBase
Definition: PlotBase.h:34
Muon::MomentumTruthPullPlots::~MomentumTruthPullPlots
~MomentumTruthPullPlots()
Definition: MomentumTruthPullPlots.cxx:21
python.copyTCTOutput.sDir
sDir
Definition: copyTCTOutput.py:60
ConvertOldUJHistosToNewHistos.etaBins
list etaBins
Definition: ConvertOldUJHistosToNewHistos.py:145
test_pyathena.pt
pt
Definition: test_pyathena.py:11
PlotBase::Book2D
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
Muon::MomentumTruthPullPlots::dp_ME_truthIP_vs_pt
TH2 * dp_ME_truthIP_vs_pt
Definition: MomentumTruthPullPlots.h:28
Muon::MomentumTruthPullPlots::dp_ME_truthIP_MS_truthMS_vs_pt
TH2 * dp_ME_truthIP_MS_truthMS_vs_pt
Definition: MomentumTruthPullPlots.h:29
SG::ConstAccessor< float >
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
Muon::MomentumTruthPullPlots::initializePlots
void initializePlots()
Definition: MomentumTruthPullPlots.cxx:23
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
PlotBase::Book1D
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
InDet::ExclusiveOrigin::Primary
@ Primary
Definition: InDetTrackTruthOriginDefs.h:163
xAOD::TrackParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TrackParticle_v1.cxx:129
Muon::MomentumTruthPullPlots::dp_eloss_vs_pt
TH2 * dp_eloss_vs_pt
Definition: MomentumTruthPullPlots.h:30
Muon::MomentumTruthPullPlots::MomentumTruthPullPlots
MomentumTruthPullPlots(PlotBase *pParent, const std::string &sDir, std::string sType)
Definition: MomentumTruthPullPlots.cxx:16
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
Muon::MomentumTruthPullPlots::dp_ME_truthIP_MS_truthMS
TH1 * dp_ME_truthIP_MS_truthMS
Definition: MomentumTruthPullPlots.h:24
Muon::MomentumTruthPullPlots::dp_ME_truthIP_vs_eta
TH2 * dp_ME_truthIP_vs_eta
Definition: MomentumTruthPullPlots.h:33
Trk::Combined
@ Combined
Definition: TrackSummaryTool.h:32
Muon::MomentumTruthPullPlots::m_sType
std::string m_sType
Definition: MomentumTruthPullPlots.h:20
xAOD::TruthParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TruthParticle_v1.cxx:174
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::MomentumTruthPullPlots::dp_eloss
TH1 * dp_eloss
Definition: MomentumTruthPullPlots.h:25
Muon::MomentumTruthPullPlots::dp_ME_truthIP
TH1 * dp_ME_truthIP
Definition: MomentumTruthPullPlots.h:23
Muon::MomentumTruthPullPlots::dp_CB_truthIP_vs_eta
TH2 * dp_CB_truthIP_vs_eta
Definition: MomentumTruthPullPlots.h:32
MomentumTruthPullPlots.h
xAOD::TruthParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TruthParticle_v1.cxx:166
Muon::MomentumTruthPullPlots::dp_eloss_vs_eta
TH2 * dp_eloss_vs_eta
Definition: MomentumTruthPullPlots.h:35
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Muon::MomentumTruthPullPlots::dp_CB_truthIP
TH1 * dp_CB_truthIP
Definition: MomentumTruthPullPlots.h:22
Muon::MomentumTruthPullPlots::dp_ME_truthIP_MS_truthMS_vs_eta
TH2 * dp_ME_truthIP_MS_truthMS_vs_eta
Definition: MomentumTruthPullPlots.h:34
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAOD::TruthParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TruthParticle_v1.cxx:196
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
Muon::MomentumTruthPullPlots::dp_CB_truthIP_vs_pt
TH2 * dp_CB_truthIP_vs_pt
Definition: MomentumTruthPullPlots.h:27
TrackingPrimitives.h
Muon::MomentumTruthPullPlots::fill
void fill(const xAOD::Muon &muon, const xAOD::TrackParticle *muontpIP, const xAOD::TruthParticle &truthprt, float weight=1.0)
Definition: MomentumTruthPullPlots.cxx:49