ATLAS Offline Software
Loading...
Searching...
No Matches
MuonSegmentPlots.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <cmath>
8
12
13namespace Muon {
14
16constexpr int chIdxMax = static_cast<int>(ChIdx::ChIndexMax);
17
18MuonSegmentPlots::MuonSegmentPlots(PlotBase* pParent, const std::string& sDir)
19 : PlotBase(pParent, sDir) {
20
21 // booking histograms
23 "segmentfitChi2", "Segment fit #chi^{2};#chi^{2};Entries", 100, 0, 200);
24 segmentfitNdof = Book1D("segmentfitNdof",
25 "Segment fit N_{dof};N_{dof};Entries", 100, 0, 20);
27 "segmentfitChi2oNdof",
28 "Segment fit #chi^{2}/N_{dof};Segment fit #chi^{2}/N_{dof};Entries",
29 100, 0, 20);
30
31 t0 = Book1D("t0", "Segment Refit t_{0};t_{0};Entries", 100, -25, 25);
32 t0_top = Book1D("t0_top", "Segment Refit t_{0} for y>0;t_{0};Entries", 100,
33 -25, 25);
34 t0_bottom = Book1D("t0_bottom", "Segment Refit t_{0} for y<0;t_{0};Entries",
35 100, -25, 25);
36 t0err = Book1D("t0err", "Segment Refit t_{0} error;t_{0} error;Entries",
37 100, 0, 10);
38 t0err_top = Book1D("t0err_top",
39 "Segment Refit t_{0} error for y>0;t_{0} error;Entries",
40 100, 0, 10);
42 "t0err_bottom", "Segment Refit t_{0} error for y<0;t_{0} error;Entries",
43 100, 0, 10);
44
45 nPrecisionHits = Book1D("nPrecisionHits",
46 "Segment precision hits;hits;Entries", 20, 0, 20);
47 nPhiLayers = Book1D("nPhiLayers", "Segment phi layers;#phi layers;Entries",
48 10, 0, 10);
50 "nTrigEtaLayers",
51 "Segment eta trigger layers;#eta trigger layers;Entries", 10, 0, 10);
53 "nPrecisionHits_nTriggerHits",
54 "Number of MDT hits vs Tigger station hits; MDT hits; Trigger hits", 20,
55 -0.5, 19.5, 20, -0.5, 19.5);
56
57 etaIndex = Book1D("etaIndex", "Segment #eta Index ;#eta index;Entries", 21,
58 -10.5, 10.5);
59 sector = Book1D("sector", "Segment phi sector;#phi sector;Entries", 16, 0.5,
60 16.5);
61
63 Book2D("xypos_barrel", "Segment position x-y, barrel;x_{pos};y_{pos}",
64 150, -14000, 14000, 150, -14000, 14000);
66 Book2D("xypos_endcap", "Segment position x-y, endcap;x_{pos};y_{pos}",
67 150, -14000, 14000, 150, -14000, 14000);
68 rzpos_sectorLarge = Book2D("rzpos_sectorLarge",
69 "Segment position r-z, large sectors normalized "
70 "by solid angle;z_{pos};r_{pos}",
71 100, -23000, 23000, 75, 0, 14000);
72
73 rzpos_sectorSmall = Book2D("rzpos_sectorSmall",
74 "Segment position r-z, small sectors normalized "
75 "by solid angle;z_{pos};r_{pos}",
76 100, -23000, 23000, 75, 0, 14000);
77
78 etadir =
79 Book1D("etadir", "Segment pointing direction eta;#eta_{dir};Entries",
80 100, -5, 5);
82 Book1D("etadir_barrel",
83 "Segment pointing direction eta, barrel;#eta_{dir};Entries", 100,
84 -5, 5);
86 Book1D("etadir_endcap",
87 "Segment pointing direction eta, endcap;#eta_{dir};Entries", 100,
88 -5, 5);
89 phidir =
90 Book1D("phidir", "Segment pointing direction phi;#phi_{dir};Entries",
91 64, -3.2, 3.2);
92 etaphidir =
93 Book2D("etaphidir",
94 "Segment pointing direction phi vs eta;#eta_{dir};#phi_{dir}",
95 64, -3.2, 3.2, 64, -3.2, 3.2);
96
97 chamberIndex = Book1D("chamberIndex", "Chamber index; Chamber Index",
98 chIdxMax, 0, chIdxMax);
100 Book2D("chamberIndex_perSector",
101 "Number of Segments per Chamber, normalized by solid angle; "
102 "Sector; Chamber Index ",
103 33, -16.5, 16.5, chIdxMax, 0, chIdxMax);
105 Book2D("eff_chamberIndex_perSector_numerator",
106 "Number of expected hits for Segments per Chamber; Sector; "
107 "Chamber Index ",
108 33, -16.5, 16.5, chIdxMax, 0, chIdxMax);
110 Book2D("eff_chamberIndex_perSector_denominator",
111 "Number of recorded precision hits for Segments per Chamber; "
112 "Sector; Chamber Index ",
113 33, -16.5, 16.5, chIdxMax, 0, chIdxMax);
115 "eff_chamberIndex_perSector",
116 "precision layer hit efficiency per chamber; Sector; Chamber Index ",
117 33, -16.5, 16.5, chIdxMax, 0, chIdxMax);
118 // chamberIndex_dtheta = Book2D("chamberIndex_dtheta","Segment #Delta#theta
119 // between position and momentum; #Delta#theta; Chamber Index ", 180,
120 // -90.0, 90.0, chIdxMax,0,chIdxMax);
121 for (int i = 1; i <= chamberIndex->GetXaxis()->GetNbins(); i++) {
122 const char* temp_chambername =
124 chamberIndex->GetBinLowEdge(i)))
125 .c_str();
126 chamberIndex->GetXaxis()->SetBinLabel(i, temp_chambername);
127 chamberIndex_perSector->GetYaxis()->SetBinLabel(i, temp_chambername);
128 eff_chamberIndex_perSector_numerator->GetYaxis()->SetBinLabel(
129 i, temp_chambername);
130 eff_chamberIndex_perSector_denominator->GetYaxis()->SetBinLabel(
131 i, temp_chambername);
132 eff_chamberIndex_perSector->GetYaxis()->SetBinLabel(i,
133 temp_chambername);
134
135 sector_etaIndex.push_back(
136 Book2D(Form("%s_etastation", temp_chambername),
137 Form("Number of Segment in %s; #phi Sector; #eta Index",
138 temp_chambername),
139 18, -0.5, 17.5, 19, -9.5, 9.5));
141 Form("%s_etastation_nPrechit", temp_chambername),
142 Form("Number of Segment Prec hit in %s; #phi Sector; #eta Index",
143 temp_chambername),
144 18, -0.5, 17.5, 19, -9.5, 9.5));
145 sector_etaIndex_nTrighit.push_back(
146 Book2D(Form("%s_etastation_nTrighit", temp_chambername),
147 Form("Number of Segment Phi + Trigeta hit in %s; #phi "
148 "Sector; #eta Index",
149 temp_chambername),
150 18, -0.5, 17.5, 19, -9.5, 9.5));
152 Book2D(Form("eff_%s_etastation_nPrechit", temp_chambername),
153 Form("Segment Prec hit eff in %s; #phi Sector; #eta Index",
154 temp_chambername),
155 18, -0.5, 17.5, 19, -9.5, 9.5));
157 Form("eff_%s_etastation_nTrighit", temp_chambername),
158 Form("Segment Phi + Trigeta hit eff in %s; #phi Sector; #eta Index",
159 temp_chambername),
160 18, -0.5, 17.5, 19, -9.5, 9.5));
161 }
162}
163
165
166void MuonSegmentPlots::fill(const xAOD::MuonSegment& muSeg, float weight) {
167 float chi2 = muSeg.chiSquared();
168 float ndof = muSeg.numberDoF();
169 segmentfitChi2->Fill(chi2, weight);
170 segmentfitNdof->Fill(ndof, weight);
171 if (ndof > 0) {
172 segmentfitChi2oNdof->Fill(muSeg.chiSquared() / muSeg.numberDoF(),
173 weight);
174 }
175
176 float x = muSeg.x();
177 float y = muSeg.y();
178
179 float segt0 = muSeg.t0();
180 float segt0err = muSeg.t0error();
181
182 t0->Fill(segt0, weight);
183 t0err->Fill(segt0err, weight);
184 if (y > 0) {
185 t0_top->Fill(segt0, weight);
186 t0err_top->Fill(segt0err, weight);
187 } else {
188 t0_bottom->Fill(segt0, weight);
189 t0err_bottom->Fill(segt0err, weight);
190 }
191
192 sector->Fill(muSeg.sector(), weight);
193 etaIndex->Fill(muSeg.etaIndex(), weight);
194
195 nPrecisionHits->Fill(muSeg.nPrecisionHits(), weight);
196 nPhiLayers->Fill(muSeg.nPhiLayers(), weight);
197 nTrigEtaLayers->Fill(muSeg.nTrigEtaLayers(), weight);
198 // not sure how to implement weights here JEF 8/4/2021
200 muSeg.nPrecisionHits(), muSeg.nPhiLayers() + muSeg.nTrigEtaLayers(),
201 weight);
202
203 // not sure how to implement weights here for these chamber/sector Index
204 // plots JEF 8/4/2021
205 int chIndex = static_cast<int>(muSeg.chamberIndex());
206 float chambernorm =
207 1 / Chamberarea[chIndex]; // weight of the segment using the chamber
208 // eta-phi area
209 chamberIndex->Fill(chIndex, weight);
210 int sectorIndex = muSeg.sector();
211 int etaIndex = muSeg.etaIndex();
212 // fill the count of segments; switch the sign here to make the plots
213 if (muSeg.z() < 0) {
214 sectorIndex = -sectorIndex;
215 }
216 chamberIndex_perSector->Fill(sectorIndex, chIndex, chambernorm * weight);
218 sectorIndex, chIndex,
219 weight * ((muSeg.nPrecisionHits() > Chamberexpectedhits[chIndex])
221 : muSeg.nPrecisionHits()));
223 sectorIndex, chIndex, weight * Chamberexpectedhits[chIndex]);
224 // update sector eta index plots; switch the sign back here to make the
225 // plots
226 sectorIndex = muSeg.sector();
227 sector_etaIndex[chIndex]->Fill(sectorIndex,
228 etaIndex); // for weighted average
229 // double currentfill =
230 // sector_etaIndex[chIndex]->GetBinContent(sector_etaIndex[chIndex]->GetXaxis()->FindBin(sectorIndex),
231 // sector_etaIndex[chIndex]->GetYaxis()->FindBin(etaIndex));
232 sector_etaIndex_nPrechit[chIndex]->Fill(sectorIndex, etaIndex,
233 weight * muSeg.nPrecisionHits());
235 sectorIndex, etaIndex,
236 weight * (muSeg.nPhiLayers() + muSeg.nTrigEtaLayers()));
238 sectorIndex, etaIndex, weight * Chamberexpectedhits[chIndex]);
240 sectorIndex, etaIndex, weight * Chamberexpectedtrighits[chIndex]);
241
242 bool isBarrel = (chIndex < static_cast<int>(ChIdx::BEE))
243 ? true
244 : false; // BEE -> endcap
245 bool isSectorLarge = ((isBarrel && chIndex % 2 == 1) ||
246 (!isBarrel && chIndex % 2 == 0 &&
247 chIndex != static_cast<int>(ChIdx::BEE)))
248 ? true
249 : false;
250
251 // position and direction plots
252 const Amg::Vector3D globalPos(muSeg.position());
253 const Amg::Vector3D globalDir(muSeg.direction());
254
255 // protect against cases with no hit information or segments parallell to
256 // the beam!
257 if (globalDir.mag() <= FLT_EPSILON || globalDir.perp() <= FLT_EPSILON) {
258 return;
259 }
260 // set up direction vectors
261 float r = globalPos.perp();
262 float z = globalPos.z();
263 // fill the rz plots
264 if (isSectorLarge) {
265 rzpos_sectorLarge->Fill(z, r, chambernorm * weight);
266 } else {
267 rzpos_sectorSmall->Fill(z, r, chambernorm * weight);
268 }
269
270 float eta = globalDir.eta();
271 float phi = globalDir.phi();
272 etadir->Fill(eta, weight);
273 phidir->Fill(phi, weight);
274 etaphidir->Fill(eta, phi);
275
276 if (isBarrel) {
277 xypos_barrel->Fill(x, y, chambernorm * weight);
278 etadir_barrel->Fill(eta, weight);
279 } else {
280 xypos_endcap->Fill(x, y, chambernorm * weight);
281 etadir_endcap->Fill(eta, weight);
282 }
283}
284
285} // namespace Muon
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define y
#define x
#define z
std::vector< TH2 * > sector_etaIndex
std::vector< TH2 * > eff_sector_etaIndex_nTrighit
static constexpr std::array< float, 17 > Chamberarea
static constexpr std::array< float, 17 > Chamberexpectedhits
MuonSegmentPlots(PlotBase *pParent, const std::string &sDir)
std::vector< TH2 * > sector_etaIndex_nPrechit
std::vector< TH2 * > eff_sector_etaIndex_nPrechit
void fill(const xAOD::MuonSegment &muonSeg, float weight=1.0)
static constexpr std::array< float, 17 > Chamberexpectedtrighits
std::vector< TH2 * > sector_etaIndex_nTrighit
TH1D * Book1D(std::string_view name, std::string_view labels, int nBins, float start, float end, bool prependDir=true)
Book a TH1D histogram.
Definition PlotBase.cxx:94
PlotBase(PlotBase *parent, std::string_view sDir)
Definition PlotBase.cxx:29
TH2F * Book2D(std::string_view name, std::string_view labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, bool prependDir=true)
Book a TH2F histogram.
Definition PlotBase.cxx:123
float y() const
Returns the x position.
float t0() const
int nTrigEtaLayers() const
Returns the number of trigger eta layers.
float numberDoF() const
Returns the numberDoF.
int nPrecisionHits() const
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
float chiSquared() const
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
int nPhiLayers() const
Returns the number of phi layers.
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
float t0error() const
Returns the time error.
float z() const
Returns the y position.
double chi2(TH1 *h0, TH1 *h1)
int r
Definition globals.cxx:22
Eigen::Matrix< double, 3, 1 > Vector3D
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
bool isBarrel(const ChIndex index)
Returns true if the chamber index points to a barrel chamber.
const std::string & chName(ChIndex index)
convert ChIndex into a string
ChIndex
enum to classify the different chamber layers in the muon spectrometer
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
constexpr int chIdxMax
MuonStationIndex::ChIndex ChIdx
MuonSegment_v1 MuonSegment
Reference the current persistent version: