ATLAS Offline Software
MuonSegmentPlots.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include <cmath>
10 
11 namespace Muon{
12 
13 MuonSegmentPlots::MuonSegmentPlots(PlotBase* pParent, const std::string& sDir): PlotBase(pParent, sDir) {
14 
15  //booking histograms
16  segmentfitChi2 = Book1D("segmentfitChi2", "Segment fit #chi^{2};#chi^{2};Entries", 100,0,200);
17  segmentfitNdof = Book1D("segmentfitNdof", "Segment fit N_{dof};N_{dof};Entries", 100,0,20);
18  segmentfitChi2oNdof = Book1D("segmentfitChi2oNdof", "Segment fit #chi^{2}/N_{dof};Segment fit #chi^{2}/N_{dof};Entries", 100,0,20);
19 
20  t0 = Book1D("t0","Segment Refit t_{0};t_{0};Entries",100,-25,25);
21  t0_top = Book1D("t0_top","Segment Refit t_{0} for y>0;t_{0};Entries",100,-25,25);
22  t0_bottom = Book1D("t0_bottom","Segment Refit t_{0} for y<0;t_{0};Entries",100,-25,25);
23  t0err = Book1D("t0err","Segment Refit t_{0} error;t_{0} error;Entries",100,0,10);
24  t0err_top = Book1D("t0err_top","Segment Refit t_{0} error for y>0;t_{0} error;Entries",100,0,10);
25  t0err_bottom = Book1D("t0err_bottom","Segment Refit t_{0} error for y<0;t_{0} error;Entries",100,0,10);
26 
27  nPrecisionHits = Book1D("nPrecisionHits","Segment precision hits;hits;Entries",20,0,20);
28  nPhiLayers = Book1D("nPhiLayers","Segment phi layers;#phi layers;Entries",10,0,10);
29  nTrigEtaLayers = Book1D("nTrigEtaLayers","Segment eta trigger layers;#eta trigger layers;Entries",10,0,10);
30  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);
31 
32  etaIndex = Book1D("etaIndex","Segment #eta Index ;#eta index;Entries",21,-10.5,10.5);
33  sector = Book1D("sector","Segment phi sector;#phi sector;Entries",16,0.5,16.5);
34 
35 
36  xypos_barrel = Book2D("xypos_barrel","Segment position x-y, barrel;x_{pos};y_{pos}",150,-14000,14000,150,-14000,14000);
37  xypos_endcap = Book2D("xypos_endcap","Segment position x-y, endcap;x_{pos};y_{pos}",150,-14000,14000,150,-14000,14000);
38  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);
39 
40  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);
41 
42 
43  etadir = Book1D("etadir","Segment pointing direction eta;#eta_{dir};Entries",100,-5,5);
44  etadir_barrel = Book1D("etadir_barrel","Segment pointing direction eta, barrel;#eta_{dir};Entries",100,-5,5);
45  etadir_endcap = Book1D("etadir_endcap","Segment pointing direction eta, endcap;#eta_{dir};Entries",100,-5,5);
46  phidir = Book1D("phidir","Segment pointing direction phi;#phi_{dir};Entries",64,-3.2,3.2);
47  etaphidir = Book2D("etaphidir","Segment pointing direction phi vs eta;#eta_{dir};#phi_{dir}",64,-3.2,3.2,64,-3.2,3.2);
48 
49  chamberIndex = Book1D("chamberIndex","Chamber index; Chamber Index",Muon::MuonStationIndex::ChIndexMax,0,Muon::MuonStationIndex::ChIndexMax);
50  chamberIndex_perSector = Book2D("chamberIndex_perSector","Number of Segments per Chamber, normalized by solid angle; Sector; Chamber Index ", 33, -16.5, 16.5, Muon::MuonStationIndex::ChIndexMax,0,Muon::MuonStationIndex::ChIndexMax);
51  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, Muon::MuonStationIndex::ChIndexMax,0,Muon::MuonStationIndex::ChIndexMax);
52  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, Muon::MuonStationIndex::ChIndexMax,0,Muon::MuonStationIndex::ChIndexMax);
53  eff_chamberIndex_perSector = Book2D("eff_chamberIndex_perSector","precision layer hit efficiency per chamber; Sector; Chamber Index ", 33, -16.5, 16.5, Muon::MuonStationIndex::ChIndexMax,0,Muon::MuonStationIndex::ChIndexMax);
54  //chamberIndex_dtheta = Book2D("chamberIndex_dtheta","Segment #Delta#theta between position and momentum; #Delta#theta; Chamber Index ", 180, -90.0, 90.0, Muon::MuonStationIndex::ChIndexMax,0,Muon::MuonStationIndex::ChIndexMax);
55  for (int i=1; i<=chamberIndex->GetXaxis()->GetNbins(); i++){
56  const char *temp_chambername = Muon::MuonStationIndex::chName((Muon::MuonStationIndex::ChIndex)chamberIndex->GetBinLowEdge(i)).c_str();
57  chamberIndex->GetXaxis()->SetBinLabel(i, temp_chambername);
58  chamberIndex_perSector->GetYaxis()->SetBinLabel(i, temp_chambername);
59  eff_chamberIndex_perSector_numerator->GetYaxis()->SetBinLabel(i, temp_chambername);
60  eff_chamberIndex_perSector_denominator->GetYaxis()->SetBinLabel(i, temp_chambername);
61  eff_chamberIndex_perSector->GetYaxis()->SetBinLabel(i, temp_chambername);
62 
63  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));
64  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));
65  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));
66  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));
67  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));
68  }
69 }
70 
72 
74 {
75  float chi2 = muSeg.chiSquared();
76  float ndof = muSeg.numberDoF();
79  if (ndof>0) segmentfitChi2oNdof->Fill(muSeg.chiSquared()/muSeg.numberDoF(), weight);
80 
81  float x=muSeg.x();
82  float y=muSeg.y();
83 
84  float segt0 = muSeg.t0();
85  float segt0err = muSeg.t0error();
86 
87  t0->Fill(segt0,weight);
88  t0err->Fill(segt0err,weight);
89  if (y>0) {
90  t0_top->Fill(segt0,weight);
91  t0err_top->Fill(segt0err,weight);
92  } else {
93  t0_bottom->Fill(segt0,weight);
94  t0err_bottom->Fill(segt0err,weight);
95  }
96 
97  sector->Fill(muSeg.sector(),weight);
98  etaIndex->Fill(muSeg.etaIndex(),weight);
99 
101  nPhiLayers->Fill(muSeg.nPhiLayers(),weight);
103  // not sure how to implement weights here JEF 8/4/2021
105 
106 
107  // not sure how to implement weights here for these chamber/sector Index plots JEF 8/4/2021
108  int chIndex = muSeg.chamberIndex();
109  float chambernorm = 1/Chamberarea[chIndex];//weight of the segment using the chamber eta-phi area
110  chamberIndex->Fill(chIndex,weight);
111  int sectorIndex = muSeg.sector();
112  int etaIndex = muSeg.etaIndex();
113  //fill the count of segments; switch the sign here to make the plots
114  if (muSeg.z() < 0) { sectorIndex = - sectorIndex;}
115  chamberIndex_perSector->Fill(sectorIndex, chIndex, chambernorm*weight);
116  eff_chamberIndex_perSector_numerator->Fill(sectorIndex, chIndex, weight*((muSeg.nPrecisionHits() > Chamberexpectedhits[chIndex]) ? Chamberexpectedhits[chIndex]:muSeg.nPrecisionHits()));
118  //update sector eta index plots; switch the sign back here to make the plots
119  sectorIndex = muSeg.sector();
120  sector_etaIndex[chIndex]->Fill(sectorIndex, etaIndex);//for weighted average
121  //double currentfill = sector_etaIndex[chIndex]->GetBinContent(sector_etaIndex[chIndex]->GetXaxis()->FindBin(sectorIndex), sector_etaIndex[chIndex]->GetYaxis()->FindBin(etaIndex));
122  sector_etaIndex_nPrechit[chIndex]->Fill(sectorIndex, etaIndex, weight*muSeg.nPrecisionHits());
123  sector_etaIndex_nTrighit[chIndex]->Fill(sectorIndex, etaIndex, weight*(muSeg.nPhiLayers() + muSeg.nTrigEtaLayers()));
124  eff_sector_etaIndex_nPrechit[chIndex]->Fill(sectorIndex, etaIndex, weight*Chamberexpectedhits[chIndex]);
125  eff_sector_etaIndex_nTrighit[chIndex]->Fill(sectorIndex, etaIndex, weight*Chamberexpectedtrighits[chIndex]);
126 
127  bool isBarrel = (chIndex<Muon::MuonStationIndex::BEE)? true: false; // BEE -> endcap
128  bool isSectorLarge = ( (isBarrel && chIndex%2==1) || (!isBarrel && chIndex%2==0 && chIndex!=Muon::MuonStationIndex::BEE) )? true : false;
129 
130 
131  //position and direction plots
132  const Amg::Vector3D globalPos(muSeg.x(),muSeg.y(),muSeg.z());
133  const Amg::Vector3D globalDir(muSeg.px(),muSeg.py(),muSeg.pz());
134 
135  //protect against cases with no hit information or segments parallell to the beam!
136  if ( globalDir.mag() <= FLT_EPSILON || globalDir.perp() <= FLT_EPSILON) return;
137  //set up direction vectors
138  float r = globalPos.perp();
139  float z = globalPos.z();
140  //fill the rz plots
141  if (isSectorLarge) {rzpos_sectorLarge->Fill(z,r, chambernorm*weight);}
142  else {rzpos_sectorSmall->Fill(z,r, chambernorm*weight);}
143 
144  float eta = globalDir.eta();
145  float phi = globalDir.phi();
146  etadir->Fill(eta,weight);
147  phidir->Fill(phi,weight);
148  etaphidir->Fill(eta,phi);
149 
150 
151  if (isBarrel) {
152  xypos_barrel->Fill(x,y, chambernorm*weight);
154  } else {
155  xypos_endcap->Fill(x,y, chambernorm*weight);
157  }
158 
159 }
160 
161 } // closing namespace Muon
Muon::MuonStationIndex::chName
static const std::string & chName(ChIndex index)
convert ChIndex into a string
Definition: MuonStationIndex.cxx:157
TH2::Fill
int Fill(double, double)
Definition: rootspy.cxx:382
xAOD::MuonSegment_v1::numberDoF
float numberDoF() const
Returns the numberDoF.
beamspotman.r
def r
Definition: beamspotman.py:676
IDTPM::ndof
float ndof(const U &p)
Definition: TrackParametersHelper.h:142
Muon::MuonSegmentPlots::t0_top
TH1 * t0_top
Definition: MuonSegmentPlots.h:30
Muon::MuonSegmentPlots::sector_etaIndex
std::vector< TH2 * > sector_etaIndex
Definition: MuonSegmentPlots.h:63
PlotBase::Book1D
TH1F * 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:88
Muon::MuonSegmentPlots::eff_chamberIndex_perSector
TH2 * eff_chamberIndex_perSector
Definition: MuonSegmentPlots.h:60
xAOD::MuonSegment_v1::x
float x() const
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
PlotBase
Definition: PlotBase.h:33
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
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
xAOD::MuonSegment_v1::nTrigEtaLayers
int nTrigEtaLayers() const
Returns the number of trigger eta layers.
python.copyTCTOutput.sDir
sDir
Definition: copyTCTOutput.py:60
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 TH2D histogram.
Definition: PlotBase.cxx:117
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
xAOD::MuonSegment_v1::pz
float pz() const
Returns the pz.
Muon::MuonSegmentPlots::t0err_top
TH1 * t0err_top
Definition: MuonSegmentPlots.h:33
xAOD::MuonSegment_v1::px
float px() const
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
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
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:200
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:92
z
#define z
Muon::MuonSegmentPlots::nPrecisionHits_nTriggerHits
TH2 * nPrecisionHits_nTriggerHits
Definition: MuonSegmentPlots.h:39
xAOD::MuonSegment_v1::t0error
float t0error() const
Returns the time error.
xAOD::MuonSegment_v1::py
float py() const
Returns the py.
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
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
TH1::Fill
int Fill(double)
Definition: rootspy.cxx:285
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
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::MuonStationIndex::ChIndexMax
@ ChIndexMax
Definition: MuonStationIndex.h:19
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::MuonStationIndex::BEE
@ BEE
Definition: MuonStationIndex.h:17
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
Muon::MuonStationIndex::ChIndex
ChIndex
enum to classify the different chamber layers in the muon spectrometer
Definition: MuonStationIndex.h:15
MuonSegmentPlots.h
MuonStationIndex.h
Muon::MuonSegmentPlots::fill
void fill(const xAOD::MuonSegment &muonSeg, float weight=1.0)
Definition: MuonSegmentPlots.cxx:73
Muon::MuonSegmentPlots::MuonSegmentPlots
MuonSegmentPlots(PlotBase *pParent, const std::string &sDir)
Definition: MuonSegmentPlots.cxx:13
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()