ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCalibSegment.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <algorithm>
8#include <iostream>
9
11#include "GaudiKernel/MsgStream.h"
12
13namespace MuonCalib {
14
18
21 m_chi2 = other.chi2();
22 m_dy0 = other.error_dy0();
23 m_dtheta = other.error_dtheta();
24 m_localPosition = other.position();
25 m_localDirection = other.direction();
26 m_localToGlobal = other.localToGlobal();
27 m_qualityFlag = other.qualityFlag();
28 m_author = other.author();
29 m_fittedT0 = other.m_fittedT0; // don't use function as it would return 0 if m_fittedT0 == -99999.
30
31 m_mdtHitsOnTrack.clear();
32 for (const MdtHitPtr& mdt_it : other.mdtHOT()) { addHitOnTrack(new MdtCalibHitBase(*mdt_it)); }
33
34 m_mdtCloseHits.clear();
35 for (const MdtHitPtr& mdt_it : other.mdtClose()) { addCloseHit(new MdtCalibHitBase(*mdt_it)); }
36
37 m_cscHitsOnTrack.clear();
38 for (const CscHitPtr& csc_it : other.cscHOT()) { addHitOnTrack(new CscCalibHitBase(*csc_it)); }
39 for (const CscHitPtr& csc_it : other.cscClose()) { addCloseHit(new CscCalibHitBase(*csc_it)); }
40
41 m_rpcHitsOnTrack.clear();
42 for (const RpcHitPtr& rpc_it : other.rpcHOT()) { addHitOnTrack(new RpcCalibHitBase(*rpc_it)); }
43
44 m_rpcCloseHits.clear();
45 for (const RpcHitPtr& rpc_it : other.rpcClose()) { addCloseHit(new RpcCalibHitBase(*rpc_it)); }
46
47 m_tgcHitsOnTrack.clear();
48 for (const TgcHitPtr& tgc_it : other.tgcHOT()) { addHitOnTrack(new TgcCalibHitBase(*tgc_it)); }
49
50 m_tgcCloseHits.clear();
51 for (const TgcHitPtr& tgc_it : other.tgcClose()) { addCloseHit(new TgcCalibHitBase(*tgc_it)); }
52 }
53
56 if (this != &other) { copy(other); }
57 return *this;
58 }
59 unsigned int MuonCalibSegment::hitsPerML(int ML) const {
60 int counter{0};
61 for (const MdtHitPtr& hit_it : mdtHOT()) { counter += (hit_it->identify().mdtMultilayer() == ML); }
62 return counter;
63 }
64
65 std::ostream& MuonCalibSegment::dump(std::ostream& stream) const {
66 stream << "MuonCalibSegment with chi2 " << chi2() << std::endl;
67 stream << " -- local position " << position() << " direction " << direction() << std::endl;
68 stream << " -- HitsOnTrack " << hitsOnTrack() << std::endl;
69
70 // Dump MdtCalibHit
71 for (const MdtHitPtr& mdt_it : mdtHOT()) { mdt_it->dump(stream); }
72 stream << " -- CloseHits " << mdtCloseHits() << std::endl;
73 for (const MdtHitPtr& mdt_it : mdtClose()) { mdt_it->dump(stream); }
74
75 // Dump CscCalibHit
76 for (const CscHitPtr& csc_it : cscHOT()) { csc_it->dump(stream); }
77 stream << " -- CloseHits " << cscCloseHits() << std::endl;
78 for (const CscHitPtr& csc_it : cscClose()) { csc_it->dump(stream); }
79
80 // Dump RpcCalibHit
81 for (const RpcHitPtr& rpc_it : rpcHOT()) { rpc_it->dump(stream); }
82 stream << " -- CloseHits " << rpcCloseHits() << std::endl;
83 for (const RpcHitPtr& rpc_it : rpcClose()) { rpc_it->dump(stream); }
84
85 // Dump TgcCalibHit
86 for (const TgcHitPtr& tgc_it : tgcHOT()) { tgc_it->dump(stream); }
87 stream << " -- CloseHits " << tgcCloseHits() << std::endl;
88 for (const TgcHitPtr& tgc_it : tgcClose()) { tgc_it->dump(stream); }
89
90 return stream;
91 } // end MuonCalibSegment::dump
92
93 void MuonCalibSegment::refineMdtSelection(const std::vector<unsigned int>& new_selection) {
94 if (new_selection.size() != m_mdtHitsOnTrack.size()) {
95 MsgStream log(Athena::getMessageSvc(), "MuonCalibSegment");
96 log << MSG::WARNING << "MuonCalibSegment::refineMdtSelection: Wrong size of vector!" << endmsg;
97 return;
98 }
99 // copy old hit vector
100 MdtHitVec old_hit_vec(m_mdtHitsOnTrack);
101 m_mdtHitsOnTrack.clear();
102 for (unsigned int i = 0; i < old_hit_vec.size(); i++) {
103 if (!new_selection[i]) {
104 m_mdtHitsOnTrack.emplace_back(old_hit_vec[i]);
105 } else {
106 m_mdtCloseHits.emplace_back(old_hit_vec[i]);
107 }
108 }
109 } // end MuonCalibSegment::refineMdtSelection
110
112 double MuonCalibSegment::fittedT0() const { return hasFittedT0() ? m_fittedT0 : 0; }
113
115 m_localPosition = pos;
116 m_localDirection = dir;
117 }
124
125 int MuonCalibSegment::author() const { return m_author; }
126 unsigned int MuonCalibSegment::qualityFlag() const { return m_qualityFlag; }
127
128 void MuonCalibSegment::set(double chi2, const Amg::Vector3D& pos, const Amg::Vector3D& dir) {
129 m_chi2 = chi2;
130 m_localPosition = pos;
131 m_localDirection = dir;
132 }
133
134 // member access
135 unsigned int MuonCalibSegment::hitsOnTrack() const { return m_mdtHitsOnTrack.size() + m_cscHitsOnTrack.size(); }
136
137 unsigned int MuonCalibSegment::closeHits() const { return m_mdtCloseHits.size(); }
138
139 // number of hits in segment
140 unsigned int MuonCalibSegment::missedHits() const { return outOfTimeHits() + emptyTubes(); }
141 unsigned int MuonCalibSegment::deltaHits() const { return m_qualityFlag % 10; }
142 unsigned int MuonCalibSegment::emptyTubes() const { return (m_qualityFlag % 1000) / 100; }
143 unsigned int MuonCalibSegment::outOfTimeHits() const { return (m_qualityFlag % 100) / 10; }
144
145 // MDT specific
146 unsigned int MuonCalibSegment::mdtHitsOnTrack() const { return m_mdtHitsOnTrack.size(); }
149
150 unsigned int MuonCalibSegment::mdtCloseHits() const { return m_mdtCloseHits.size(); }
153
154 // CSC specific
155 unsigned int MuonCalibSegment::cscHitsOnTrack() const { return m_cscHitsOnTrack.size(); }
158
159 unsigned int MuonCalibSegment::cscCloseHits() const { return m_cscCloseHits.size(); }
162
163 // RPC specific
164 unsigned int MuonCalibSegment::rpcHitsOnTrack() const { return m_rpcHitsOnTrack.size(); }
167
168 unsigned int MuonCalibSegment::rpcCloseHits() const { return m_rpcCloseHits.size(); }
171
172 // TGC specific
173 unsigned int MuonCalibSegment::tgcHitsOnTrack() const { return m_tgcHitsOnTrack.size(); }
176
177 unsigned int MuonCalibSegment::tgcCloseHits() const { return m_tgcCloseHits.size(); }
180
181 // local track parameters
182 double MuonCalibSegment::chi2() const { return m_chi2; }
183 double MuonCalibSegment::error_dy0() const { return m_dy0; }
184 double MuonCalibSegment::error_dtheta() const { return m_dtheta; }
188
191
192 // methodes to add CalibHitBase's
195
198
201
204
205 void MuonCalibSegment::addHitOnTrack(const MdtHitPtr& hit) { m_mdtHitsOnTrack.emplace_back(hit); }
206 void MuonCalibSegment::addCloseHit(const MdtHitPtr& hit) { m_mdtCloseHits.emplace_back(hit); }
207
208 void MuonCalibSegment::addHitOnTrack(const CscHitPtr& hit) { m_cscHitsOnTrack.emplace_back(hit); }
209 void MuonCalibSegment::addCloseHit(const CscHitPtr& hit) { m_cscCloseHits.emplace_back(hit); }
210
211 void MuonCalibSegment::addHitOnTrack(const RpcHitPtr& hit) { m_rpcHitsOnTrack.emplace_back(hit); }
212 void MuonCalibSegment::addCloseHit(const RpcHitPtr& hit) { m_rpcCloseHits.emplace_back(hit); }
213
214 void MuonCalibSegment::addHitOnTrack(const TgcHitPtr& hit) { m_tgcHitsOnTrack.emplace_back(hit); }
215 void MuonCalibSegment::addCloseHit(const TgcHitPtr& hit) { m_tgcCloseHits.emplace_back(hit); }
216
217} // namespace MuonCalib
218
219std::ostream& operator<<(std::ostream& stream, const MuonCalib::MuonCalibSegment& seg) { return seg.dump(stream); }
#define endmsg
static Double_t t0
std::ostream & operator<<(std::ostream &stream, const MuonCalib::MuonCalibSegment &seg)
Athena-independent part of the CscCalibHit.
Athena-independent part of the MdtCalibHit.
A MuonCalibSegment is a reconstructed three dimensional track segment in the MuonSpectrometer.
unsigned int qualityFlag() const
retrieve the Fit quality flag
Amg::Vector3D m_localDirection
direction in station (local) coordinates
double m_chi2
goodness of (DC)fit
double error_dy0() const
retrieve error position
void addCloseHit(MdtCalibHitBase *hit)
add the mdt hit to the set nearby the segment
unsigned int missedHits() const
number of missed hits of this segment (out of time + empty tubes)
unsigned int mdtHitsOnTrack() const
retrieve the number of MdtCalibHitBase s assigned to this segment
const CscHitVec & cscClose() const
retrieve the full set of nearby mdt hits of this segment.
unsigned int tgcCloseHits() const
retrieve the number of nearby tgc hits.
TgcHitVec m_tgcHitsOnTrack
set of TgcCalibHitBase s assigned to the segment
void refineMdtSelection(const std::vector< unsigned int > &new_selection)
move trck hits to close hits
RpcHitVec m_rpcHitsOnTrack
set of RpcCalibHitBase s assigned to the segment
const MdtHitVec & mdtClose() const
retrieve the full set of nearby mdt hits of this segment.
std::vector< RpcHitPtr > RpcHitVec
double error_dtheta() const
retrieve error angle
const Amg::Transform3D & localToGlobal() const
CscHitVec m_cscHitsOnTrack
set of CscCalibHitBase s assigned to the segment
const Amg::Vector3D & direction() const
retrieve local direction of segment (on station level) retrieve the transformation from local chamber...
unsigned int emptyTubes() const
number of empty tubes of this segment
const RpcHitVec & rpcClose() const
retrieve the full set of nearby mdt hits of this segment.
unsigned int rpcCloseHits() const
retrieve the number of nearby rpc hits.
unsigned int deltaHits() const
number of delta hits of this segment
std::shared_ptr< MdtCalibHitBase > MdtHitPtr
typedef for a collection of MdtCalibHitBase s
unsigned int rpcHitsOnTrack() const
retrieve the number of RpcCalibHitBase s assigned to this segment
std::shared_ptr< const RpcCalibHitBase > RpcHitPtr
typedef for a collection of RpcCalibHitBase s
RpcHitVec m_rpcCloseHits
set of rpc hits nearby the segment
void setAuthor(int author)
sets author field
void setErrors(double error_dy0, double error_dtheta)
sets Local errors on MuonCalibSegment parameters
bool hasFittedT0() const
check whether t0 was fitted
const CscHitVec & cscHOT() const
retrieve the full set of CscCalibHitBase s assigned to this segment
MdtHitVec m_mdtCloseHits
set of mdt hits nearby the segment
std::vector< MdtHitPtr > MdtHitVec
void copy(const MuonCalibSegment &other)
std::ostream & dump(std::ostream &stream) const
unsigned int m_qualityFlag
flag describing the fit quality
unsigned int hitsPerML(int ML) const
number of hits per multilayer of this segment
std::shared_ptr< const TgcCalibHitBase > TgcHitPtr
typedef for a collection of TgcCalibHitBase s
TgcHitVec m_tgcCloseHits
set of tgc hits nearby the segment
std::shared_ptr< const CscCalibHitBase > CscHitPtr
typedef for a collection of CscCalibHitBase s
int author() const
retrieve the segment author
unsigned int hitsOnTrack() const
retrieve the sum of all XxxCalibHits assigned to the MuonCalibSegment
Amg::Vector3D m_localPosition
position in station (local) coordinates
double m_dy0
error on local position
std::vector< TgcHitPtr > TgcHitVec
double m_dtheta
error on local direction
unsigned int mdtCloseHits() const
retrieve the number of nearby mdt hits.
double chi2() const
retrieve chi2
const MdtHitVec & mdtHOT() const
retrieve the full set of MdtCalibHitBase s assigned to this segment
CscHitVec m_cscCloseHits
set of csc hits nearby the segment
std::vector< CscHitPtr > CscHitVec
const TgcHitVec & tgcClose() const
retrieve the full set of nearby mdt hits of this segment.
Amg::Vector3D globalPosition() const
retrieve global position
MuonCalibSegment & operator=(const MuonCalibSegment &seg)
assignment operator
MuonCalibSegment(double chi2, const Amg::Vector3D &pos, const Amg::Vector3D &dir, const Amg::Transform3D &locToGlo, unsigned int qualityFlag=0)
constructor fully initializing the segment-parameters, do we need default constructor?
void addHitOnTrack(MdtCalibHitBase *hit)
add the MdtCalibHitBase to the set assigned to the segment
void set(double chi2, const Amg::Vector3D &pos, const Amg::Vector3D &dir)
double fittedT0() const
retrieve fitted T0, return -99999 if no fit was performed
unsigned int closeHits() const
retrieve the sum of all hits close to the MuonCalibSegment.
const TgcHitVec & tgcHOT() const
retrieve the full set of TgcCalibHitBase s assigned to this segment
void setFittedT0(double t0)
sets t0 field
Amg::Vector3D globalDirection() const
retrieve global direction
unsigned int cscHitsOnTrack() const
retrieve the number of CscCalibHitBase s assigned to this segment
static constexpr double s_dummy_ctor_dbl
const RpcHitVec & rpcHOT() const
retrieve the full set of RpcCalibHitBase s assigned to this segment
const Amg::Vector3D & position() const
retrieve local position of segment (on station level)
unsigned int cscCloseHits() const
retrieve the number of nearby csc hits.
void setSegment(const Amg::Vector3D &pos, const Amg::Vector3D &dir)
unsigned int outOfTimeHits() const
number of hits out of time of this segment
unsigned int tgcHitsOnTrack() const
retrieve the number of TgcCalibHitBase s assigned to this segment
virtual ~MuonCalibSegment()
destructor
Amg::Transform3D m_localToGlobal
transformation local->global
Athena independent part of the RpcCalibHit.
Athena independent part of the TgcCalibHit.
singleton-like access to IMessageSvc via open function and helper
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
IMessageSvc * getMessageSvc(bool quiet=false)
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.