ATLAS Offline Software
MuonSegmentSlimPlots.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
10 
11 namespace Muon{
12 
14 constexpr int chIdxMax = static_cast<int>(ChIdx::ChIndexMax);
15 
16 MuonSegmentSlimPlots::MuonSegmentSlimPlots(PlotBase* pParent, const std::string& sDir): PlotBase(pParent, sDir) {
17 
18  //booking histograms
19  segmentfitChi2 = Book1D("segmentfitChi2", "Segment fit #chi^{2};#chi^{2};Entries", 100,0,200);
20  segmentfitNdof = Book1D("segmentfitNdof", "Segment fit N_{dof};N_{dof};Entries", 100,0,20);
21  segmentfitChi2oNdof = Book1D("segmentfitChi2oNdof", "Segment fit #chi^{2}/N_{dof};Segment fit #chi^{2}/N_{dof};Entries", 100,0,20);
22 
23  t0 = Book1D("t0","Segment Refit t_{0};t_{0};Entries",100,-25,25);
24  t0_top = Book1D("t0_top","Segment Refit t_{0} for y>0;t_{0};Entries",100,-25,25);
25  t0_bottom = Book1D("t0_bottom","Segment Refit t_{0} for y<0;t_{0};Entries",100,-25,25);
26  t0err = Book1D("t0err","Segment Refit t_{0} error;t_{0} error;Entries",100,0,10);
27  t0err_top = Book1D("t0err_top","Segment Refit t_{0} error for y>0;t_{0} error;Entries",100,0,10);
28  t0err_bottom = Book1D("t0err_bottom","Segment Refit t_{0} error for y<0;t_{0} error;Entries",100,0,10);
29 
30  nPrecisionHits = Book1D("nPrecisionHits","Segment precision hits;hits;Entries",20,0,20);
31  nPhiLayers = Book1D("nPhiLayers","Segment phi layers;#phi layers;Entries",10,0,10);
32  nTrigEtaLayers = Book1D("nTrigEtaLayers","Segment eta trigger layers;#eta trigger layers;Entries",10,0,10);
33 
34  etaIndex = Book1D("etaIndex","Segment #eta Index ;#eta index;Entries",21,-10.5,10.5);
35  sector = Book1D("sector","Segment phi sector;#phi sector;Entries",16,0.5,16.5);
36 
37  etadir = Book1D("etadir","Segment pointing direction eta;#eta_{dir};Entries",100,-5,5);
38  etadir_barrel = Book1D("etadir_barrel","Segment pointing direction eta, barrel;#eta_{dir};Entries",100,-5,5);
39  etadir_endcap = Book1D("etadir_endcap","Segment pointing direction eta, endcap;#eta_{dir};Entries",100,-5,5);
40  phidir = Book1D("phidir","Segment pointing direction phi;#phi_{dir};Entries",64,-3.2,3.2);
41  etaphidir = Book2D("etaphidir","Segment pointing direction phi vs eta;#eta_{dir};#phi_{dir}",64,-3.2,3.2,64,-3.2,3.2);
42 
43  chamberIndex = Book1D("chamberIndex","Chamber index; Chamber Index",chIdxMax,0, chIdxMax);
44  chamberIndex_perSector = Book2D("chamberIndex_perSector","Number of Segments per Chamber, normalized by solid angle; Sector; Chamber Index ", 33, -16.5, 16.5, chIdxMax,0,chIdxMax);
45  eff_chamberIndex_perSector_numerator = Book2D("eff_chamberIndex_perSector_numerator","Number of expected hits for Segments per Chamber; Sector; Chamber Index ", 33, -16.5, 16.5, chIdxMax,0,chIdxMax);
46  eff_chamberIndex_perSector_denominator = Book2D("eff_chamberIndex_perSector_denominator","Number of recorded precision hits for Segments per Chamber; Sector; Chamber Index ", 33, -16.5, 16.5, chIdxMax,0,chIdxMax);
47  eff_chamberIndex_perSector = Book2D("eff_chamberIndex_perSector","precision layer hit efficiency per chamber; Sector; Chamber Index ", 33, -16.5, 16.5, chIdxMax,0,chIdxMax);
48  //chamberIndex_dtheta = Book2D("chamberIndex_dtheta","Segment #Delta#theta between position and momentum; #Delta#theta; Chamber Index ", 180, -90.0, 90.0, chIdxMax,0,chIdxMax);
49  for (int i=1; i<=chamberIndex->GetXaxis()->GetNbins(); i++){
50  const char *temp_chambername = MuonStationIndex::chName(static_cast<Muon::MuonStationIndex::ChIndex>(chamberIndex->GetBinLowEdge(i))).c_str();
51  chamberIndex->GetXaxis()->SetBinLabel(i, temp_chambername);
52  chamberIndex_perSector->GetYaxis()->SetBinLabel(i, temp_chambername);
53  eff_chamberIndex_perSector_numerator->GetYaxis()->SetBinLabel(i, temp_chambername);
54  eff_chamberIndex_perSector_denominator->GetYaxis()->SetBinLabel(i, temp_chambername);
55  eff_chamberIndex_perSector->GetYaxis()->SetBinLabel(i, temp_chambername);
56  }
57 }
58 
60 {
61 }
62 
64 {
65  float chi2 = muSeg.chiSquared();
66  float ndof = muSeg.numberDoF();
67  segmentfitChi2->Fill(chi2, weight);
68  segmentfitNdof->Fill(ndof, weight);
69  if (ndof>0) segmentfitChi2oNdof->Fill(muSeg.chiSquared()/muSeg.numberDoF(), weight);
70 
71  float y=muSeg.y();
72 
73  float segt0 = muSeg.t0();
74  float segt0err = muSeg.t0error();
75 
76  t0->Fill(segt0, weight);
77  t0err->Fill(segt0err, weight);
78  if (y>0) {
79  t0_top->Fill(segt0, weight);
80  t0err_top->Fill(segt0err,weight);
81  } else {
82  t0_bottom->Fill(segt0, weight);
83  t0err_bottom->Fill(segt0err, weight);
84  }
85 
86  sector->Fill(muSeg.sector(), weight);
87 
88  nPrecisionHits->Fill(muSeg.nPrecisionHits(), weight);
89  nPhiLayers->Fill(muSeg.nPhiLayers(), weight);
90  nTrigEtaLayers->Fill(muSeg.nTrigEtaLayers(), weight);
91 
92  int chIndex = static_cast<int>(muSeg.chamberIndex());
93  float chambernorm = 1/Chamberarea[chIndex];//weight of the segment using the chamber eta-phi area
94  chamberIndex->Fill(chIndex, weight);
95  int sectorIndex = muSeg.sector();
96  //fill the count of segments; switch the sign here to make the plots
97  if (muSeg.z() < 0) { sectorIndex = - sectorIndex;}
98  chamberIndex_perSector->Fill(sectorIndex, chIndex, chambernorm);
99  eff_chamberIndex_perSector_numerator->Fill(sectorIndex, chIndex, (muSeg.nPrecisionHits() > Chamberexpectedhits[chIndex]) ? Chamberexpectedhits[chIndex]:muSeg.nPrecisionHits());
100  eff_chamberIndex_perSector_denominator->Fill(sectorIndex, chIndex, Chamberexpectedhits[chIndex]);
101  //update sector eta index plots; switch the sign back here to make the plots
102  sectorIndex = muSeg.sector();
103 
104  //position and direction plots
105  //protect against cases with no hit information!
106  Amg::Vector3D globalDir{muSeg.px(),muSeg.py(),muSeg.pz()};
107 
108  if ( globalDir.mag() < DBL_EPSILON ) return;
109 
110  float eta = globalDir.eta();
111  float phi = globalDir.phi();
112  etadir->Fill(eta, weight);
113  phidir->Fill(phi, weight);
114  etaphidir->Fill(eta,phi);
115 
116 }
117 
118 
119 } // closing namespace Muon
Muon::MuonStationIndex::chName
static const std::string & chName(ChIndex index)
convert ChIndex into a string
Definition: MuonStationIndex.cxx:157
xAOD::MuonSegment_v1::numberDoF
float numberDoF() const
Returns the numberDoF.
IDTPM::ndof
float ndof(const U &p)
Definition: TrackParametersHelper.h:134
Muon::MuonSegmentSlimPlots::segmentfitChi2
TH1 * segmentfitChi2
Definition: MuonSegmentSlimPlots.h:25
Muon::MuonSegmentSlimPlots::t0_bottom
TH1 * t0_bottom
Definition: MuonSegmentSlimPlots.h:31
PlotBase
Definition: PlotBase.h:34
Muon::MuonSegmentSlimPlots::MuonSegmentSlimPlots
MuonSegmentSlimPlots(PlotBase *pParent, const std::string &sDir)
Definition: MuonSegmentSlimPlots.cxx:16
Muon::MuonSegmentSlimPlots::chamberIndex_perSector
TH2 * chamberIndex_perSector
Definition: MuonSegmentSlimPlots.h:49
Muon::MuonSegmentSlimPlots::segmentfitNdof
TH1 * segmentfitNdof
Definition: MuonSegmentSlimPlots.h:26
xAOD::MuonSegment_v1::chiSquared
float chiSquared() const
xAOD::MuonSegment_v1::nTrigEtaLayers
int nTrigEtaLayers() const
Returns the number of trigger eta layers.
python.copyTCTOutput.sDir
sDir
Definition: copyTCTOutput.py:60
Muon::ChIdx
MuonStationIndex::ChIndex ChIdx
Definition: MuonSegmentPlots.cxx:13
Muon::MuonSegmentSlimPlots::etadir_barrel
TH1 * etadir_barrel
Definition: MuonSegmentSlimPlots.h:43
Muon::MuonSegmentSlimPlots::etadir_endcap
TH1 * etadir_endcap
Definition: MuonSegmentSlimPlots.h:44
Muon::MuonSegmentSlimPlots::chamberIndex
TH1 * chamberIndex
Definition: MuonSegmentSlimPlots.h:48
Muon::MuonSegmentSlimPlots::etadir
TH1 * etadir
Definition: MuonSegmentSlimPlots.h:42
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
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
xAOD::MuonSegment_v1::pz
float pz() const
Returns the pz.
xAOD::MuonSegment_v1::px
float px() const
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
Muon::MuonSegmentSlimPlots::nTrigEtaLayers
TH1 * nTrigEtaLayers
Definition: MuonSegmentSlimPlots.h:38
Muon::MuonSegmentSlimPlots::segmentfitChi2oNdof
TH1 * segmentfitChi2oNdof
Definition: MuonSegmentSlimPlots.h:27
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
Muon::MuonSegmentSlimPlots::eff_chamberIndex_perSector_numerator
TH2 * eff_chamberIndex_perSector_numerator
Definition: MuonSegmentSlimPlots.h:50
GeoPrimitives.h
xAOD::MuonSegment_v1::t0
float t0() const
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::MuonSegment_v1::t0error
float t0error() const
Returns the time error.
Muon::MuonSegmentSlimPlots::t0_top
TH1 * t0_top
Definition: MuonSegmentSlimPlots.h:30
xAOD::MuonSegment_v1::py
float py() const
Returns the py.
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:523
MuonSegmentSlimPlots.h
Muon::MuonSegmentSlimPlots::nPrecisionHits
TH1 * nPrecisionHits
Definition: MuonSegmentSlimPlots.h:36
xAOD::MuonSegment_v1::nPhiLayers
int nPhiLayers() const
Returns the number of phi layers.
Muon::MuonSegmentSlimPlots::eff_chamberIndex_perSector
TH2 * eff_chamberIndex_perSector
Definition: MuonSegmentSlimPlots.h:52
Muon::MuonSegmentSlimPlots::Chamberarea
static constexpr std::array< float, 17 > Chamberarea
Definition: MuonSegmentSlimPlots.h:54
Muon::MuonSegmentSlimPlots::nPhiLayers
TH1 * nPhiLayers
Definition: MuonSegmentSlimPlots.h:37
Muon::MuonSegmentSlimPlots::~MuonSegmentSlimPlots
~MuonSegmentSlimPlots()
Definition: MuonSegmentSlimPlots.cxx:59
Muon::MuonSegmentSlimPlots::t0
TH1 * t0
Definition: MuonSegmentSlimPlots.h:29
xAOD::MuonSegment_v1::nPrecisionHits
int nPrecisionHits() const
Muon::MuonSegmentSlimPlots::sector
TH1 * sector
Definition: MuonSegmentSlimPlots.h:41
Muon::MuonSegmentSlimPlots::t0err_bottom
TH1 * t0err_bottom
Definition: MuonSegmentSlimPlots.h:34
Muon::MuonSegmentSlimPlots::t0err_top
TH1 * t0err_top
Definition: MuonSegmentSlimPlots.h:33
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::MuonSegmentSlimPlots::phidir
TH1 * phidir
Definition: MuonSegmentSlimPlots.h:45
xAOD::MuonSegment_v1::z
float z() const
Returns the y position.
Muon::MuonSegmentSlimPlots::eff_chamberIndex_perSector_denominator
TH2 * eff_chamberIndex_perSector_denominator
Definition: MuonSegmentSlimPlots.h:51
Muon::MuonSegmentSlimPlots::Chamberexpectedhits
static constexpr std::array< float, 17 > Chamberexpectedhits
Definition: MuonSegmentSlimPlots.h:58
Muon::MuonSegmentSlimPlots::etaIndex
TH1 * etaIndex
Definition: MuonSegmentSlimPlots.h:40
xAOD::MuonSegment_v1::sector
int sector() const
y
#define y
xAOD::MuonSegment_v1::y
float y() const
Returns the x position.
Muon::MuonStationIndex::ChIndex
ChIndex
enum to classify the different chamber layers in the muon spectrometer
Definition: MuonStationIndex.h:15
Muon::MuonSegmentSlimPlots::fill
void fill(const xAOD::MuonSegment &muonSeg, float weight=1.0)
Definition: MuonSegmentSlimPlots.cxx:63
MuonStationIndex.h
TrackingPrimitives.h
Muon::MuonSegmentSlimPlots::t0err
TH1 * t0err
Definition: MuonSegmentSlimPlots.h:32
xAOD::MuonSegment_v1::chamberIndex
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Muon::MuonSegmentSlimPlots::etaphidir
TH2 * etaphidir
Definition: MuonSegmentSlimPlots.h:46
Muon::chIdxMax
constexpr int chIdxMax
Definition: MuonSegmentPlots.cxx:14