ATLAS Offline Software
MuonPrintingTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "MuonPrintingTool.h"
12 
13 #include "AthLinks/ElementLink.h"
18 #include "TrkTrack/Track.h"
19 #include "TrkTrack/TrackInfo.h"
22 
24 Rec::MuonPrintingTool::MuonPrintingTool(const std::string& type, const std::string& name, const IInterface* parent) :
26  declareInterface<IMuonPrintingTool>(this);
27 }
28 
31 
34  ATH_CHECK(m_edmPrinter.retrieve());
35  ATH_MSG_DEBUG("Retrieved " << m_edmPrinter);
36 
37  ATH_MSG_INFO("Initialize() successful in " << name());
38  return StatusCode::SUCCESS;
39 }
40 
43  ATH_MSG_DEBUG("Nothing to finalize.");
44  return StatusCode::SUCCESS;
45 }
46 
48  std::ostringstream sout;
49  sout << " pt : " << tp.pt() << " eta : " << tp.eta() << " phi : " << tp.phi();
50  return sout.str();
51 }
52 
53 std::string Rec::MuonPrintingTool::print(const xAOD::Muon& muon) const {
54  std::ostringstream sout;
55 
56  sout << "##### Muon, pt : " << muon.pt() << " eta : " << muon.eta() << " phi : " << muon.phi() << " mass : " << muon.m()
57  << " author " << muon.author() << " type : " << muon.muonType() << " secondary authors: ";
58  for (int a = 0; a < xAOD::Muon::NumberOfMuonAuthors; ++a) {
60  if (author != muon.author() && muon.isAuthor(author)) sout << " " << a;
61  }
62  sout << std::endl;
63 
64  sout << " ParamDef available:" << std::endl;
65  float spectrometerFieldIntegral = 0;
67  sout << " spectrometerFieldIntegral : " << spectrometerFieldIntegral << std::endl;
70  sout << " scatteringCurvatureSignificance : " << scatteringCurvatureSignificance << std::endl;
73  sout << " scatteringNeighbourSignificance : " << scatteringNeighbourSignificance << std::endl;
76  sout << " momentumBalanceSignificance : " << momentumBalanceSignificance << std::endl;
77  float segmentDeltaEta = 0;
78  if (muon.parameter(segmentDeltaEta, xAOD::Muon::segmentDeltaEta)) sout << " segmentDeltaEta : " << segmentDeltaEta << std::endl;
79  float segmentDeltaPhi = 0;
80  if (muon.parameter(segmentDeltaPhi, xAOD::Muon::segmentDeltaPhi)) sout << " segmentDeltaPhi : " << segmentDeltaPhi << std::endl;
81  float segmentChi2OverDoF = 0;
83  sout << " segmentChi2OverDoF : " << segmentChi2OverDoF << std::endl;
84  float t0 = 0;
85  if (muon.parameter(t0, xAOD::Muon::t0)) sout << " t0 : " << t0 << std::endl;
86  float beta = 0;
87  if (muon.parameter(beta, xAOD::Muon::beta)) sout << " beta : " << beta << std::endl;
88  float annBarrel = 0;
89  if (muon.parameter(annBarrel, xAOD::Muon::annBarrel)) sout << " annBarrel : " << annBarrel << std::endl;
90  float annEndCap = 0;
91  if (muon.parameter(annEndCap, xAOD::Muon::annEndCap)) sout << " annEndCap : " << annEndCap << std::endl;
92  float innAngle = 0;
93  if (muon.parameter(innAngle, xAOD::Muon::innAngle)) sout << " innAngle : " << innAngle << std::endl;
94  float midAngle = 0;
95  if (muon.parameter(midAngle, xAOD::Muon::midAngle)) sout << " midAngle : " << midAngle << std::endl;
96  float msInnerMatchChi2 = 0;
97  if (muon.parameter(msInnerMatchChi2, xAOD::Muon::msInnerMatchChi2)) sout << " msInnerMatchChi2 : " << msInnerMatchChi2 << std::endl;
98  int msInnerMatchDOF = 0;
99  if (muon.parameter(msInnerMatchDOF, xAOD::Muon::msInnerMatchDOF)) sout << " msInnerMatchDOF : " << msInnerMatchDOF << std::endl;
100  float msOuterMatchChi2 = 0;
101  if (muon.parameter(msOuterMatchChi2, xAOD::Muon::msOuterMatchChi2)) sout << " msOuterMatchChi2 : " << msOuterMatchChi2 << std::endl;
102  int msOuterMatchDOF = 0;
103  if (muon.parameter(msOuterMatchDOF, xAOD::Muon::msOuterMatchDOF)) sout << " msOuterMatchDOF : " << msOuterMatchDOF << std::endl;
104  float meanDeltaADCCountsMDT = 0;
105  if (muon.parameter(meanDeltaADCCountsMDT, xAOD::Muon::meanDeltaADCCountsMDT))
106  sout << " meanDeltaADCCountsMDT : " << meanDeltaADCCountsMDT << std::endl;
107  float CaloLRLikelihood = 0;
108  if (muon.parameter(CaloLRLikelihood, xAOD::Muon::CaloLRLikelihood)) sout << " CaloLRLikelihood : " << CaloLRLikelihood << std::endl;
109  float CaloMuonScore = 0;
110  if (muon.parameter(CaloLRLikelihood, xAOD::Muon::CaloMuonScore)) sout << " CaloMuonScore : " << CaloMuonScore << std::endl;
111  int CaloMuonIDTag = 0;
112  if (muon.parameter(CaloMuonIDTag, xAOD::Muon::CaloMuonIDTag)) sout << " CaloMuonIDTag : " << CaloMuonIDTag << std::endl;
113  float FSR_CandidateEnergy = 0;
114  if (muon.parameter(FSR_CandidateEnergy, xAOD::Muon::FSR_CandidateEnergy))
115  sout << " FSR_CandidateEnergy : " << FSR_CandidateEnergy << std::endl;
116  float EnergyLoss = 0;
117  if (muon.parameter(EnergyLoss, xAOD::Muon::EnergyLoss)) sout << " EnergyLoss : " << EnergyLoss << std::endl;
118  float ParamEnergyLoss = 0;
119  if (muon.parameter(ParamEnergyLoss, xAOD::Muon::ParamEnergyLoss)) sout << " ParamEnergyLoss : " << ParamEnergyLoss << std::endl;
120  float MeasEnergyLoss = 0;
121  if (muon.parameter(MeasEnergyLoss, xAOD::Muon::MeasEnergyLoss)) sout << " MeasEnergyLoss : " << MeasEnergyLoss << std::endl;
122  float EnergyLossSigma = 0;
123  if (muon.parameter(EnergyLossSigma, xAOD::Muon::EnergyLossSigma)) sout << " EnergyLossSigma : " << EnergyLossSigma << std::endl;
124  float ParamEnergyLossSigmaPlus = 0;
125  if (muon.parameter(ParamEnergyLossSigmaPlus, xAOD::Muon::ParamEnergyLossSigmaPlus))
126  sout << " ParamEnergyLossSigmaPlus : " << ParamEnergyLossSigmaPlus << std::endl;
127  float ParamEnergyLossSigmaMinus = 0;
128  if (muon.parameter(ParamEnergyLossSigmaMinus, xAOD::Muon::ParamEnergyLossSigmaMinus))
129  sout << " ParamEnergyLossSigmaMinus : " << ParamEnergyLossSigmaMinus << std::endl;
130  float MeasEnergyLossSigma = 0;
131  if (muon.parameter(MeasEnergyLossSigma, xAOD::Muon::MeasEnergyLossSigma))
132  sout << " MeasEnergyLossSigma : " << MeasEnergyLossSigma << std::endl;
133  uint8_t energyLossType = muon.energyLossType();
134  // if(muon.parameter(energyLossType, xAOD::Muon::EnergyLossType))
135  sout << " EnergyLossType : " << static_cast<int>(energyLossType) << std::endl;
136 
137  uint8_t nprecisionLayers = 0;
138  uint8_t nprecisionHoleLayers = 0;
139  uint8_t nphiLayers = 0;
140  uint8_t ntrigEtaLayers = 0;
141  uint8_t nphiHoleLayers = 0;
142  uint8_t ntrigEtaHoleLayers = 0;
143  uint8_t mainSector = 0;
144  uint8_t secondSector = 0;
145  if (muon.primaryTrackParticleLink().isValid()) {
146  const xAOD::TrackParticle& tp = **muon.primaryTrackParticleLink();
147  if (!tp.summaryValue(nprecisionLayers, xAOD::numberOfPrecisionLayers)) nprecisionLayers = 0;
148  if (!tp.summaryValue(nprecisionHoleLayers, xAOD::numberOfPrecisionHoleLayers)) nprecisionHoleLayers = 0;
149  if (!tp.summaryValue(nphiLayers, xAOD::numberOfPhiLayers)) nphiLayers = 0;
150  if (!tp.summaryValue(nphiHoleLayers, xAOD::numberOfPhiHoleLayers)) nphiHoleLayers = 0;
151  if (!tp.summaryValue(ntrigEtaLayers, xAOD::numberOfTriggerEtaLayers)) ntrigEtaLayers = 0;
152  if (!tp.summaryValue(ntrigEtaHoleLayers, xAOD::numberOfTriggerEtaHoleLayers)) ntrigEtaHoleLayers = 0;
153  } else
154  sout << " No valid primaryTrackParticleLink for this muon" << std::endl;
155 
156  if (!muon.summaryValue(mainSector, xAOD::primarySector)) mainSector = 0;
157  if (!muon.summaryValue(secondSector, xAOD::secondarySector)) secondSector = 0;
158  sout << " Station Layers: precision " << static_cast<int>(nprecisionLayers) << " holes " << static_cast<int>(nprecisionHoleLayers)
159  << " phi " << static_cast<int>(nphiLayers) << " holes " << static_cast<int>(nphiHoleLayers) << " trigEta "
160  << static_cast<int>(ntrigEtaLayers) << " holes " << static_cast<int>(ntrigEtaHoleLayers) << " main sector "
161  << static_cast<int>(mainSector) << " secondary " << static_cast<int>(secondSector) << std::endl;
162 
163  bool printMeasurements = true;
164 
165  if (muon.combinedTrackParticleLink().isValid()) {
166  const xAOD::TrackParticle* cbtp = *muon.combinedTrackParticleLink();
167  if (cbtp) {
168  sout << " --- Combined Muon track --- " << print(*cbtp);
169  if (!cbtp->trackLink().isValid()) {
170  sout << " No Track link";
171  ATH_MSG_DEBUG("Combined track particle without Trk::Track");
172  } else {
173  const Trk::Track* cbtr = *cbtp->trackLink();
174  if (cbtr) sout << std::endl << m_edmPrinter->printStations(*cbtr);
175  if (cbtr && printMeasurements) sout << std::endl << m_edmPrinter->printMeasurements(*cbtr);
176  }
177  sout << std::endl;
178  }
179  }
180 
181  if (muon.inDetTrackParticleLink().isValid()) {
182  const xAOD::TrackParticle* idtp = *muon.inDetTrackParticleLink();
183  if (idtp) {
184  sout << " --- InDet --- " << print(*idtp);
185 
186  if (!idtp->trackLink().isValid()) {
187  sout << " No Track link";
188  ATH_MSG_DEBUG("ID track particle without Trk::Track");
189  } else {
190  // uint8_t numberOfInnermostPixelLayerHits=0;
191  // uint8_t numberOfPixelHits=0;
192  // uint8_t numberOfSCTHits=0;
193  // uint8_t numberOfTRTHits=0;
194 
195  // if( !muon.summaryValue(numberOfInnermostPixelLayerHits,xAOD::numberOfInnermostPixelLayerHits) )
196  // numberOfInnermostPixelLayerHits = 0; if(
197  // !muon.summaryValue(numberOfPixelHits,xAOD::numberOfPixelHits) ) numberOfPixelHits = 0; if(
198  // !muon.summaryValue(numberOfSCTHits,xAOD::numberOfSCTHits) ) numberOfSCTHits = 0; if(
199  // !muon.summaryValue(numberOfTRTHits,xAOD::numberOfTRTHits) ) numberOfTRTHits = 0;
200 
201  // sout << " Hits in B Layer " << static_cast<int>(numberOfInnermostPixelLayerHits)
202  // << " Pixels " << static_cast<int>(numberOfPixelHits)
203  // << " SCT " << static_cast<int>(numberOfSCTHits)
204  // << " TRT " << static_cast<int>(numberOfTRTHits);
205  }
206  sout << std::endl;
207  }
208  }
209 
210  if (muon.extrapolatedMuonSpectrometerTrackParticleLink().isValid()) {
211  const xAOD::TrackParticle* satp = *muon.extrapolatedMuonSpectrometerTrackParticleLink();
212  if (satp) {
213  sout << " --- Extrapolated Muon track --- " << print(*satp);
214  if (!satp->trackLink().isValid()) {
215  sout << " No Track link";
216  ATH_MSG_DEBUG("Extrapolated track particle without Trk::Track");
217  } else {
218  const Trk::Track* satr = *satp->trackLink();
219  if (satr) sout << std::endl << m_edmPrinter->printStations(*satr);
220  if (satr && printMeasurements) sout << std::endl << m_edmPrinter->printMeasurements(*satr);
221  }
222  sout << std::endl;
223  }
224  }
225 
226  if (muon.muonSpectrometerTrackParticleLink().isValid()) {
227  const xAOD::TrackParticle* satp = *muon.muonSpectrometerTrackParticleLink();
228  if (satp) {
229  sout << " --- MuonSpectrometer track --- " << print(*satp);
230  if (!satp->trackLink().isValid()) {
231  sout << " No Track link";
232  ATH_MSG_DEBUG("SA track particle without Trk::Track");
233  } else {
234  const Trk::Track* satr = *satp->trackLink();
235  if (satr) sout << std::endl << m_edmPrinter->printStations(*satr);
236  if (satr && printMeasurements) sout << std::endl << m_edmPrinter->printMeasurements(*satr);
237  }
238  sout << std::endl;
239  }
240  }
241 
242  // if( !muon.muonSegments().empty() ){
243 
244  // std::vector< ElementLink< Trk::SegmentCollection > > segments = muon.muonSegments();
245  // unsigned int nseg = segments.size();
246  // sout << " --- Segments: " << nseg << std::endl;
247  // for (unsigned int i = 0; i < nseg; ++i) {
248  // const Trk::Segment* tseg = *segments[i];
249  // const Muon::MuonSegment* seg = dynamic_cast<const Muon::MuonSegment* > (tseg);
250  // sout << " " << (seg==NULL ? "not a MuonSegment!" : m_edmPrinter->print(*seg))
251  // << std::endl;
252  // }
253  // }
254 
255  return sout.str();
256 }
257 
258 std::string Rec::MuonPrintingTool::print(const xAOD::MuonContainer& muons) const {
259  std::ostringstream sout;
260  sout << "Muon Container Size :" << muons.size() << std::endl;
261 
262  for (const auto *m : muons) { sout << print(*m); }
263  return sout.str();
264 }
Rec::MuonPrintingTool::MuonPrintingTool
MuonPrintingTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: MuonPrintingTool.cxx:24
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
xAOD::primarySector
@ primarySector
primary sector crossed by the muon
Definition: TrackingPrimitives.h:327
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
xAOD::numberOfPrecisionHoleLayers
@ numberOfPrecisionHoleLayers
layers with holes AND no hits [unit8_t].
Definition: TrackingPrimitives.h:289
Rec::MuonPrintingTool::print
std::string print(const xAOD::Muon &muon) const
print muon object to a string
Definition: MuonPrintingTool.cxx:53
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
TruthParticleContainer.h
Rec::MuonPrintingTool::~MuonPrintingTool
virtual ~MuonPrintingTool()
Standard destructor.
Definition: MuonPrintingTool.cxx:30
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
MuonParameters::scatteringNeighbourSignificance
@ scatteringNeighbourSignificance
Definition: MuonParamDefs.h:135
xAOD::numberOfPhiHoleLayers
@ numberOfPhiHoleLayers
layers with trigger phi holes but no hits [unit8_t].
Definition: TrackingPrimitives.h:291
MuonParameters::innAngle
@ innAngle
common MuGirl and MuTag parameters
Definition: MuonParamDefs.h:148
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
MuonParameters::segmentDeltaPhi
@ segmentDeltaPhi
Definition: MuonParamDefs.h:140
MuonParameters::annBarrel
@ annBarrel
Definition: MuonParamDefs.h:145
MuonParameters::momentumBalanceSignificance
@ momentumBalanceSignificance
Definition: MuonParamDefs.h:136
Track.h
MaterialEffectsOnTrack.h
xAOD::numberOfTriggerEtaLayers
@ numberOfTriggerEtaLayers
layers with trigger eta hits [unit8_t].
Definition: TrackingPrimitives.h:292
xAOD::numberOfTriggerEtaHoleLayers
@ numberOfTriggerEtaHoleLayers
layers with trigger eta holes but no hits [unit8_t].
Definition: TrackingPrimitives.h:293
MuonParameters::midAngle
@ midAngle
Definition: MuonParamDefs.h:149
Rec::MuonPrintingTool::finalize
virtual StatusCode finalize()
end of the job - finalize
Definition: MuonPrintingTool.cxx:42
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonSegmentCombinationCollection.h
MuonParameters::segmentDeltaEta
@ segmentDeltaEta
MuTag parameters.
Definition: MuonParamDefs.h:139
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
MuonParameters::NumberOfMuonAuthors
@ NumberOfMuonAuthors
Definition: MuonParamDefs.h:69
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
xAOD::energyLossType
energyLossType
Definition: Muon_v1.cxx:558
MuonParameters::scatteringCurvatureSignificance
@ scatteringCurvatureSignificance
Definition: MuonParamDefs.h:134
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrackInfo.h
xAOD::TrackParticle_v1::trackLink
const ElementLink< TrackCollection > & trackLink() const
Returns a link (which can be invalid) to the Trk::Track which was used to make this TrackParticle.
Definition: TrackParticle_v1.cxx:779
xAOD::secondarySector
@ secondarySector
secondary sector crossed by the muon (set to the primary if the muon only passed one sector)
Definition: TrackingPrimitives.h:328
a
TList * a
Definition: liststreamerinfos.cxx:10
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
MuonParameters::annEndCap
@ annEndCap
Definition: MuonParamDefs.h:146
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
MuonSegment.h
MuonPrintingTool.h
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
MuonParameters::segmentChi2OverDoF
@ segmentChi2OverDoF
Definition: MuonParamDefs.h:141
AthAlgTool
Definition: AthAlgTool.h:26
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
FitQuality.h
TruthParticle.h
ParticleJetParams::Author
Author
Definition: ParticleJetParamDefs.h:33
xAOD::numberOfPhiLayers
@ numberOfPhiLayers
layers with a trigger phi hit [unit8_t].
Definition: TrackingPrimitives.h:290
Rec::MuonPrintingTool::initialize
virtual StatusCode initialize()
Overriding initialize and finalize.
Definition: MuonPrintingTool.cxx:33
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
MuonParameters::spectrometerFieldIntegral
@ spectrometerFieldIntegral
Discriminators and further variables.
Definition: MuonParamDefs.h:133
xAOD::numberOfPrecisionLayers
@ numberOfPrecisionLayers
layers with at least 3 hits [unit8_t].
Definition: TrackingPrimitives.h:288