ATLAS Offline Software
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 
11 namespace Muon{
12 
14 constexpr int chIdxMax = static_cast<int>(ChIdx::ChIndexMax);
15 
16 MuonSegmentPlots::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 
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
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
xAOD::MuonSegment_v1::numberDoF
float numberDoF() const
Returns the numberDoF.
beamspotman.r
def r
Definition: beamspotman.py:674
IDTPM::ndof
float ndof(const U &p)
Definition: TrackParametersHelper.h:134
Muon::MuonSegmentPlots::t0_top
TH1 * t0_top
Definition: MuonSegmentPlots.h:30
Muon::MuonSegmentPlots::sector_etaIndex
std::vector< TH2 * > sector_etaIndex
Definition: MuonSegmentPlots.h:63
Muon::MuonSegmentPlots::eff_chamberIndex_perSector
TH2 * eff_chamberIndex_perSector
Definition: MuonSegmentPlots.h:60
xAOD::MuonSegment_v1::x
float x() const
PlotBase
Definition: PlotBase.h:34
xAOD::MuonSegment_v1::direction
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
Definition: MuonSegment_v1.cxx:18
Muon::MuonSegmentPlots::t0_bottom
TH1 * t0_bottom
Definition: MuonSegmentPlots.h:31
Muon::MuonSegmentPlots::rzpos_sectorLarge
TH2 * rzpos_sectorLarge
Definition: MuonSegmentPlots.h:48
xAOD::MuonSegment_v1::chiSquared
float chiSquared() const
Muon::MuonSegmentPlots::etadir_barrel
TH1 * etadir_barrel
Definition: MuonSegmentPlots.h:51
xAOD::MuonSegment_v1::nTrigEtaLayers
int nTrigEtaLayers() const
Returns the number of trigger eta layers.
python.copyTCTOutput.sDir
sDir
Definition: copyTCTOutput.py:59
Muon::MuonSegmentPlots::Chamberexpectedhits
static constexpr std::array< float, 17 > Chamberexpectedhits
Definition: MuonSegmentPlots.h:73
Muon::MuonSegmentPlots::segmentfitNdof
TH1 * segmentfitNdof
Definition: MuonSegmentPlots.h:26
Muon::MuonSegmentPlots::nPhiLayers
TH1 * nPhiLayers
Definition: MuonSegmentPlots.h:37
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
Muon::MuonSegmentPlots::t0err_top
TH1 * t0err_top
Definition: MuonSegmentPlots.h:33
Muon::MuonSegmentPlots::Chamberexpectedtrighits
static constexpr std::array< float, 17 > Chamberexpectedtrighits
Definition: MuonSegmentPlots.h:77
Muon::MuonSegmentPlots::t0err_bottom
TH1 * t0err_bottom
Definition: MuonSegmentPlots.h:34
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
Muon::MuonSegmentPlots::segmentfitChi2oNdof
TH1 * segmentfitChi2oNdof
Definition: MuonSegmentPlots.h:27
Muon::MuonSegmentPlots::t0
TH1 * t0
Definition: MuonSegmentPlots.h:29
x
#define x
Muon::MuonSegmentPlots::chamberIndex_perSector
TH2 * chamberIndex_perSector
Definition: MuonSegmentPlots.h:57
Muon::MuonSegmentPlots::nPrecisionHits
TH1 * nPrecisionHits
Definition: MuonSegmentPlots.h:36
Muon::MuonSegmentPlots::phidir
TH1 * phidir
Definition: MuonSegmentPlots.h:53
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
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
GeoPrimitives.h
xAOD::MuonSegment_v1::t0
float t0() const
Muon::MuonSegmentPlots::etaIndex
TH1 * etaIndex
Definition: MuonSegmentPlots.h:41
Muon::MuonSegmentPlots::chamberIndex
TH1 * chamberIndex
Definition: MuonSegmentPlots.h:56
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
Muon::MuonStationIndex::chIndex
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
Definition: MuonStationIndex.cxx:11
Muon::MuonSegmentPlots::nPrecisionHits_nTriggerHits
TH2 * nPrecisionHits_nTriggerHits
Definition: MuonSegmentPlots.h:39
xAOD::MuonSegment_v1::t0error
float t0error() const
Returns the time error.
Muon::MuonStationIndex::chName
const std::string & chName(ChIndex index)
convert ChIndex into a string
Definition: MuonStationIndex.cxx:119
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:525
Muon::MuonSegmentPlots::sector_etaIndex_nPrechit
std::vector< TH2 * > sector_etaIndex_nPrechit
Definition: MuonSegmentPlots.h:64
Muon::MuonSegmentPlots::rzpos_sectorSmall
TH2 * rzpos_sectorSmall
Definition: MuonSegmentPlots.h:47
Muon::MuonSegmentPlots::etaphidir
TH1 * etaphidir
Definition: MuonSegmentPlots.h:54
Muon::MuonSegmentPlots::etadir_endcap
TH1 * etadir_endcap
Definition: MuonSegmentPlots.h:52
xAOD::MuonSegment_v1::nPhiLayers
int nPhiLayers() const
Returns the number of phi layers.
Muon::MuonSegmentPlots::Chamberarea
static constexpr std::array< float, 17 > Chamberarea
Definition: MuonSegmentPlots.h:69
Muon::MuonSegmentPlots::eff_chamberIndex_perSector_denominator
TH2 * eff_chamberIndex_perSector_denominator
Definition: MuonSegmentPlots.h:59
Muon::MuonStationIndex::ChIndex::BEE
@ BEE
xAOD::MuonSegment_v1::position
Amg::Vector3D position() const
Returns the position as Amg::Vector.
Definition: MuonSegment_v1.cxx:15
xAOD::MuonSegment_v1::nPrecisionHits
int nPrecisionHits() const
Muon::MuonSegmentPlots::eff_sector_etaIndex_nPrechit
std::vector< TH2 * > eff_sector_etaIndex_nPrechit
Definition: MuonSegmentPlots.h:66
Muon::MuonSegmentPlots::segmentfitChi2
TH1 * segmentfitChi2
Definition: MuonSegmentPlots.h:25
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::MuonSegmentPlots::t0err
TH1 * t0err
Definition: MuonSegmentPlots.h:32
Muon::MuonSegmentPlots::sector_etaIndex_nTrighit
std::vector< TH2 * > sector_etaIndex_nTrighit
Definition: MuonSegmentPlots.h:65
xAOD::MuonSegment_v1::z
float z() const
Returns the y position.
Muon::MuonSegmentPlots::sector
TH1 * sector
Definition: MuonSegmentPlots.h:42
Muon::MuonSegmentPlots::etadir
TH1 * etadir
Definition: MuonSegmentPlots.h:50
Muon::MuonSegmentPlots::eff_sector_etaIndex_nTrighit
std::vector< TH2 * > eff_sector_etaIndex_nTrighit
Definition: MuonSegmentPlots.h:67
xAOD::MuonSegment_v1::sector
int sector() const
y
#define y
xAOD::MuonSegment_v1::y
float y() const
Returns the x position.
xAOD::MuonSegment_v1::etaIndex
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
Muon::MuonSegmentPlots::nTrigEtaLayers
TH1 * nTrigEtaLayers
Definition: MuonSegmentPlots.h:38
python.LArCondContChannels.isBarrel
isBarrel
Definition: LArCondContChannels.py:659
Muon::MuonSegmentPlots::xypos_endcap
TH2 * xypos_endcap
Definition: MuonSegmentPlots.h:46
MuonSegmentPlots.h
Muon::MuonStationIndex::ChIndex
ChIndex
enum to classify the different chamber layers in the muon spectrometer
Definition: MuonStationIndex.h:15
MuonStationIndex.h
Muon::MuonSegmentPlots::fill
void fill(const xAOD::MuonSegment &muonSeg, float weight=1.0)
Definition: MuonSegmentPlots.cxx:76
Muon::MuonSegmentPlots::MuonSegmentPlots
MuonSegmentPlots(PlotBase *pParent, const std::string &sDir)
Definition: MuonSegmentPlots.cxx:16
Muon::MuonSegmentPlots::eff_chamberIndex_perSector_numerator
TH2 * eff_chamberIndex_perSector_numerator
Definition: MuonSegmentPlots.h:58
TrackingPrimitives.h
xAOD::MuonSegment_v1::chamberIndex
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Muon::MuonSegmentPlots::xypos_barrel
TH2 * xypos_barrel
Definition: MuonSegmentPlots.h:45
Muon::MuonSegmentPlots::~MuonSegmentPlots
~MuonSegmentPlots()
Muon::chIdxMax
constexpr int chIdxMax
Definition: MuonSegmentPlots.cxx:14