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
9#include <cmath>
10
11namespace Muon{
12
14constexpr int chIdxMax = static_cast<int>(ChIdx::ChIndexMax);
15
16MuonSegmentPlots::MuonSegmentPlots(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 nPrecisionHits_nTriggerHits = Book2D("nPrecisionHits_nTriggerHits", "Number of MDT hits vs Tigger station hits; MDT hits; Trigger hits", 20, -0.5, 19.5, 20, -0.5, 19.5);
34
35 etaIndex = Book1D("etaIndex","Segment #eta Index ;#eta index;Entries",21,-10.5,10.5);
36 sector = Book1D("sector","Segment phi sector;#phi sector;Entries",16,0.5,16.5);
37
38
39 xypos_barrel = Book2D("xypos_barrel","Segment position x-y, barrel;x_{pos};y_{pos}",150,-14000,14000,150,-14000,14000);
40 xypos_endcap = Book2D("xypos_endcap","Segment position x-y, endcap;x_{pos};y_{pos}",150,-14000,14000,150,-14000,14000);
41 rzpos_sectorLarge = Book2D("rzpos_sectorLarge","Segment position r-z, large sectors normalized by solid angle;z_{pos};r_{pos}",100,-23000,23000,75,0,14000);
42
43 rzpos_sectorSmall = Book2D("rzpos_sectorSmall","Segment position r-z, small sectors normalized by solid angle;z_{pos};r_{pos}",100,-23000,23000,75,0,14000);
44
45
46 etadir = Book1D("etadir","Segment pointing direction eta;#eta_{dir};Entries",100,-5,5);
47 etadir_barrel = Book1D("etadir_barrel","Segment pointing direction eta, barrel;#eta_{dir};Entries",100,-5,5);
48 etadir_endcap = Book1D("etadir_endcap","Segment pointing direction eta, endcap;#eta_{dir};Entries",100,-5,5);
49 phidir = Book1D("phidir","Segment pointing direction phi;#phi_{dir};Entries",64,-3.2,3.2);
50 etaphidir = Book2D("etaphidir","Segment pointing direction phi vs eta;#eta_{dir};#phi_{dir}",64,-3.2,3.2,64,-3.2,3.2);
51
52 chamberIndex = Book1D("chamberIndex","Chamber index; Chamber Index",chIdxMax,0,chIdxMax);
53 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);
54 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);
55 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);
56 eff_chamberIndex_perSector = Book2D("eff_chamberIndex_perSector","precision layer hit efficiency per chamber; Sector; Chamber Index ", 33, -16.5, 16.5, chIdxMax,0,chIdxMax);
57 //chamberIndex_dtheta = Book2D("chamberIndex_dtheta","Segment #Delta#theta between position and momentum; #Delta#theta; Chamber Index ", 180, -90.0, 90.0, chIdxMax,0,chIdxMax);
58 for (int i=1; i<=chamberIndex->GetXaxis()->GetNbins(); i++){
59 const char *temp_chambername = MuonStationIndex::chName(static_cast<MuonStationIndex::ChIndex>(chamberIndex->GetBinLowEdge(i))).c_str();
60 chamberIndex->GetXaxis()->SetBinLabel(i, temp_chambername);
61 chamberIndex_perSector->GetYaxis()->SetBinLabel(i, temp_chambername);
62 eff_chamberIndex_perSector_numerator->GetYaxis()->SetBinLabel(i, temp_chambername);
63 eff_chamberIndex_perSector_denominator->GetYaxis()->SetBinLabel(i, temp_chambername);
64 eff_chamberIndex_perSector->GetYaxis()->SetBinLabel(i, temp_chambername);
65
66 sector_etaIndex.push_back(Book2D(Form("%s_etastation", temp_chambername), Form("Number of Segment in %s; #phi Sector; #eta Index", temp_chambername), 18, -0.5, 17.5, 19, -9.5, 9.5));
67 sector_etaIndex_nPrechit.push_back(Book2D(Form("%s_etastation_nPrechit", temp_chambername), Form("Number of Segment Prec hit in %s; #phi Sector; #eta Index", temp_chambername), 18, -0.5, 17.5, 19, -9.5, 9.5));
68 sector_etaIndex_nTrighit.push_back(Book2D(Form("%s_etastation_nTrighit", temp_chambername), Form("Number of Segment Phi + Trigeta hit in %s; #phi Sector; #eta Index", temp_chambername), 18, -0.5, 17.5, 19, -9.5, 9.5));
69 eff_sector_etaIndex_nPrechit.push_back(Book2D(Form("eff_%s_etastation_nPrechit", temp_chambername), Form("Segment Prec hit eff in %s; #phi Sector; #eta Index", temp_chambername), 18, -0.5, 17.5, 19, -9.5, 9.5));
70 eff_sector_etaIndex_nTrighit.push_back(Book2D(Form("eff_%s_etastation_nTrighit", temp_chambername), Form("Segment Phi + Trigeta hit eff in %s; #phi Sector; #eta Index", temp_chambername), 18, -0.5, 17.5, 19, -9.5, 9.5));
71 }
72}
73
75
76 void MuonSegmentPlots::fill(const xAOD::MuonSegment& muSeg, float weight)
77{
78 float chi2 = muSeg.chiSquared();
79 float ndof = muSeg.numberDoF();
80 segmentfitChi2->Fill(chi2,weight);
81 segmentfitNdof->Fill(ndof,weight);
82 if (ndof>0) segmentfitChi2oNdof->Fill(muSeg.chiSquared()/muSeg.numberDoF(), weight);
83
84 float x=muSeg.x();
85 float y=muSeg.y();
86
87 float segt0 = muSeg.t0();
88 float segt0err = muSeg.t0error();
89
90 t0->Fill(segt0,weight);
91 t0err->Fill(segt0err,weight);
92 if (y>0) {
93 t0_top->Fill(segt0,weight);
94 t0err_top->Fill(segt0err,weight);
95 } else {
96 t0_bottom->Fill(segt0,weight);
97 t0err_bottom->Fill(segt0err,weight);
98 }
99
100 sector->Fill(muSeg.sector(),weight);
101 etaIndex->Fill(muSeg.etaIndex(),weight);
102
103 nPrecisionHits->Fill(muSeg.nPrecisionHits(),weight);
104 nPhiLayers->Fill(muSeg.nPhiLayers(),weight);
105 nTrigEtaLayers->Fill(muSeg.nTrigEtaLayers(),weight);
106 // not sure how to implement weights here JEF 8/4/2021
107 nPrecisionHits_nTriggerHits->Fill(muSeg.nPrecisionHits(), muSeg.nPhiLayers() + muSeg.nTrigEtaLayers(),weight);
108
109
110 // not sure how to implement weights here for these chamber/sector Index plots JEF 8/4/2021
111 int chIndex = static_cast<int>(muSeg.chamberIndex());
112 float chambernorm = 1/Chamberarea[chIndex];//weight of the segment using the chamber eta-phi area
113 chamberIndex->Fill(chIndex,weight);
114 int sectorIndex = muSeg.sector();
115 int etaIndex = muSeg.etaIndex();
116 //fill the count of segments; switch the sign here to make the plots
117 if (muSeg.z() < 0) { sectorIndex = - sectorIndex;}
118 chamberIndex_perSector->Fill(sectorIndex, chIndex, chambernorm*weight);
121 //update sector eta index plots; switch the sign back here to make the plots
122 sectorIndex = muSeg.sector();
123 sector_etaIndex[chIndex]->Fill(sectorIndex, etaIndex);//for weighted average
124 //double currentfill = sector_etaIndex[chIndex]->GetBinContent(sector_etaIndex[chIndex]->GetXaxis()->FindBin(sectorIndex), sector_etaIndex[chIndex]->GetYaxis()->FindBin(etaIndex));
125 sector_etaIndex_nPrechit[chIndex]->Fill(sectorIndex, etaIndex, weight*muSeg.nPrecisionHits());
126 sector_etaIndex_nTrighit[chIndex]->Fill(sectorIndex, etaIndex, weight*(muSeg.nPhiLayers() + muSeg.nTrigEtaLayers()));
129
130 bool isBarrel = (chIndex<static_cast<int>(ChIdx::BEE))? true: false; // BEE -> endcap
131 bool isSectorLarge = ( (isBarrel && chIndex%2==1) || (!isBarrel && chIndex%2==0 && chIndex!=static_cast<int>(ChIdx::BEE)) )? true : false;
132
133
134 //position and direction plots
135 const Amg::Vector3D globalPos(muSeg.position());
136 const Amg::Vector3D globalDir(muSeg.direction());
137
138 //protect against cases with no hit information or segments parallell to the beam!
139 if ( globalDir.mag() <= FLT_EPSILON || globalDir.perp() <= FLT_EPSILON) return;
140 //set up direction vectors
141 float r = globalPos.perp();
142 float z = globalPos.z();
143 //fill the rz plots
144 if (isSectorLarge) {rzpos_sectorLarge->Fill(z,r, chambernorm*weight);}
145 else {rzpos_sectorSmall->Fill(z,r, chambernorm*weight);}
146
147 float eta = globalDir.eta();
148 float phi = globalDir.phi();
149 etadir->Fill(eta,weight);
150 phidir->Fill(phi,weight);
151 etaphidir->Fill(eta,phi);
152
153
154 if (isBarrel) {
155 xypos_barrel->Fill(x,y, chambernorm*weight);
156 etadir_barrel->Fill(eta,weight);
157 } else {
158 xypos_endcap->Fill(x,y, chambernorm*weight);
159 etadir_endcap->Fill(eta,weight);
160 }
161
162}
163
164} // closing 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 > 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 > Chamberarea
static constexpr std::array< float, 17 > Chamberexpectedtrighits
std::vector< TH2 * > sector_etaIndex_nTrighit
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
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: