ATLAS Offline Software
Loading...
Searching...
No Matches
CscSegmentUtilTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef CscSegmentUtilTool_H
6#define CscSegmentUtilTool_H
7
8// Utilities for building segments.
9#include <string>
10#include <vector>
11
15#include "GaudiKernel/ServiceHandle.h"
16#include "GaudiKernel/ToolHandle.h"
25
26namespace Trk {
27 class PlaneSurface;
28}
29namespace Muon {
30 class MuonSegment;
31 class CscPrepData;
32} // namespace Muon
34
35class CscSegmentUtilTool : virtual public ICscSegmentUtilTool, public AthAlgTool {
36public:
37 // Constructor.
38 CscSegmentUtilTool(const std::string& type, const std::string& name, const IInterface* parent);
39
40 // Destructor.
41 virtual ~CscSegmentUtilTool() = default;
42
43 virtual StatusCode initialize();
44
45 // calls get2dMuonSegmentCombination and get4dMuonSegmentCombination with 2d segments!!
46 std::unique_ptr<std::vector<std::unique_ptr<Muon::MuonSegment> > > getMuonSegments(Identifier eta_id, Identifier phi_id,
49 const Amg::Vector3D& lpos000,
50 const EventContext& ctx) const;
51
53 // calls get2dMuonSegmentCombination and get4dMuonSegmentCombination with 2d segments!!
57 const EventContext& ctx) const;
58
60 const EventContext& ctx) const;
61
62 // get2dMuonSegmentCombination : get2dSegments does
63 // -> (1) find_2dsegments (2) find_2dseg3hit (3) add_2dsegments
67 const EventContext& ctx, int etaStat = 0, int phiStat = 0) const;
68
69 // Return the counts of spoiled and unspoiled measurements from a list
70 // of RIOS's.
71 void spoiled_count(const ICscSegmentFinder::RioList& rios, double threshold, int& nspoil, int& nunspoil);
72 void spoiled_count(const ICscSegmentFinder::RioList& rios, int& nspoil, int& nunspoil);
73 void spoiled_count(const ICscSegmentFinder::RioList& rios, int& nspoil, int& nunspoil, int& spoilmap);
74
75 // Fit a RIO residual.
76 void fit_rio_residual(const Trk::PlaneSurface& ssrf, bool dump, const ICscSegmentFinder::RioList& clus, unsigned int irclu, double& res,
77 double& dres, double& rs, double& drs // for 3pt-method
78 ) const;
79
80private:
81 Gaudi::Property<double> m_max_chisquare_tight{this, "max_chisquare_tight", 16, "for outlier removal"};
82 Gaudi::Property<double> m_max_chisquare_loose{this, "max_chisquare_loose", 2000, "for outlier removal"};
83 Gaudi::Property<double> m_max_chisquare{this, "max_chisquare", 25};
84 Gaudi::Property<double> m_max_slope_r{this, "max_slope_r", 0.2};
85 Gaudi::Property<double> m_max_slope_phi{this, "max_slope_phi", 0.2};
86 Gaudi::Property<double> m_min_xylike{this, "min_xylike", -1, "Minimum value used for xy matching of 4D segments"};
87 Gaudi::Property<double> m_fitsegment_tantheta_tolerance{this, "tantheta_update_tolerance", 0.0001};
88 Gaudi::Property<double> m_IPerror{this, "IPerror", 250};
89
90 Gaudi::Property<float> m_cluster_error_scaler{this, "cluster_error_scaler", 1};
91
92 Gaudi::Property<int> m_nunspoil{this, "UnspoiledHits", -1};
93 Gaudi::Property<int> m_max_3hitseg_sharehit{this, "max_3hitseg_sharedhit", 0};
94
95 Gaudi::Property<unsigned int> m_max_seg_per_chamber{this, "max_seg_per_chamber", 50};
96
97 Gaudi::Property<bool> m_x5data{this, "X5data", false};
98 Gaudi::Property<bool> m_zshift{this, "zshift", true};
99 Gaudi::Property<bool> m_IPconstraint{this, "IPconstraint", true};
100 Gaudi::Property<bool> m_allEtaPhiMatches{this, "allEtaPhiMatches", true};
101 Gaudi::Property<bool> m_TightenChi2{this, "TightenChi2", true};
102 Gaudi::Property<bool> m_remove4Overlap{this, "Remove4Overlap", true};
103 Gaudi::Property<bool> m_remove3Overlap{this, "Remove3Overlap", true};
104
105 ToolHandle<Muon::ICscClusterOnTrackCreator> m_rotCreator{this, "rot_creator",
106 "Muon::CscClusterOnTrackCreator/CscClusterOnTrackCreator"};
107 ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
108
109 SG::ReadCondHandleKey<CscCondDbData> m_readKey{this, "ReadKey", "CscCondDbData", "Key of CscCondDbData"};
110 SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this, "EventInfo", "EventInfo", "event info"};
111
112 SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey{this, "DetectorManagerKey", "MuonDetectorManager",
113 "Key of input MuonDetectorManager condition data"};
114
115 // Convert a local 2D segment to MuonSegment
116 Muon::MuonSegment* build_segment(const ICscSegmentFinder::Segment& seg, bool measphi, Identifier chid, bool use2Lay,
117 const EventContext& ctx) const;
118
119 // Fit a list of RIO's to form a 2D segment.
120 // The fit is relative to the passsed surface. called by fit_rio_residual
121 void fit_rio_segment(const Trk::PlaneSurface& ssrf, bool dump, const ICscSegmentFinder::RioList& clus, double& s0, double& s1,
122 double& d0, double& d1, double& d01, double& chsq, double& zshift) const;
123
124 // Fit a residual = difference between cluster position and prediction from
125 // the remaining clusters in a list.
126 // clus = list of clusters
127 // rslu is cluster for which residual is calculated
128 // res, dres = residual and error in residual // looks obsolete
129 void fit_residual(const ICscSegmentFinder::TrkClusters& clus, const Amg::Vector3D& lpos000, unsigned int irclu, double& res,
130 double& dres, const EventContext& ctx) const;
131
132 // Find segments in a chamber.
133 // calls find_outlier_cluster(Muon::CscClusterOnTrack* const clus[4]) const;
134 void find_2dsegments(bool measphi, int station, int eta, int phi, const ICscSegmentFinder::ChamberTrkClusters& clus,
135 const Amg::Vector3D& lpos000, ICscSegmentFinder::Segments& segs, double localPos, double localSlope,
136 const EventContext& ctx) const;
137
138 // Find 3 hit segments in a chamber.
139 void find_2dseg3hit(bool measphi, int station, int eta, int phi, const ICscSegmentFinder::ChamberTrkClusters& clus,
141 double localPos, double localSlope, const EventContext& ctx) const;
142
143 // Find 2 hit segments in a chamber.
144 void find_2dseg2hit(bool measphi, int station, int eta, int phi, int layStat, const ICscSegmentFinder::ChamberTrkClusters& clus,
145 const Amg::Vector3D& lpos000, ICscSegmentFinder::Segments& segs, double localPos, double localSlope,
146 const EventContext& ctx) const;
147
150
151 // Stores 2-hit segments (does overlap removal and then saves the remaining segments)
152 void add_2dseg2hits(ICscSegmentFinder::Segments& segs, ICscSegmentFinder::Segments& segs2, int layStat) const;
153
154 // Check to see if 3-hit segment is unique.
156
159 ICscSegmentFinder::Segments& phisegs, const Amg::Vector3D& lpos000, const EventContext& ctx, int etaStat = 0,
160 int phiStat = 0) const;
161
162 Muon::MuonSegment* make_4dMuonSegment(const Muon::MuonSegment& rsg, const Muon::MuonSegment& psg, bool use2LaySegsEta,
163 bool use2LaySegsPhi) const;
164
165 /***** Find outlier cluster *****/
166 /* It finds the biggest chisquare contributing cluster:
167 returns 'n' th cluster ( n = 0-3 )
168 Finding is proceeded only for N_unspoiled_clusters >=3
169 otherwise it returns -1 meaning N_unspoiled_clusters <= 2 */
170 int find_outlier_cluster(const ICscSegmentFinder::TrkClusters& clus, const Amg::Vector3D& lpos000, double& returned_chsq,
171 const EventContext& ctx) const;
172
173 /***** Fit a 2D segment. *****/
174 /* clus = input list of clusters
175 s0 = position
176 s1 = slope
177 d0, d1 and d01 = errors and correlation
178 chsq = chi-square **/
179 // void fit_segment(const ICscSegmentFinder::TrkClusters& clus, double& s0, double& s1,
180 // double& d0, double& d1, double& d01, double& chsq) const; old by Feb 15, 2010
181 // time/dtime is added in Feb 17, 2011
182 void fit_segment(const ICscSegmentFinder::TrkClusters& clus, const Amg::Vector3D& lpos000, double& s0, double& s1, double& d0,
183 double& d1, double& d01, double& chsq, double& time, double& dtime, double& zshift, const EventContext& ctx,
184 int outlierLayer = -1) const;
185
186 // fit_segment is split into several parts of detailed calculation...
187 // time/dtime is added in Feb 17, 2011
188 void fit_detailCalcPart1(const ICscSegmentFinder::TrkClusters& clus, const Amg::Vector3D& lpos000, double& s0, double& s1, double& d0,
189 double& d1, double& d01, double& chsq, bool& measphi, double& time, double& dtime, double& zshift,
190 bool IsSlopeGive, int outlierHitLayer, const EventContext& ctx) const;
191 void fit_detailCalcPart2(double q0, double q1, double q2, double q01, double q11, double q02, double& s0, double& s1, double& d0,
192 double& d1, double& d01, double& chsq) const;
193
194 double getDefaultError(Identifier id, bool measphi, const Muon::CscPrepData* prd, const EventContext& ctx) const;
195
196 void getRios(const ICscSegmentFinder::Segment& seg, ICscSegmentFinder::MbaseList* prios, bool measphi, const EventContext& ctx) const;
197 // if hit is in outlier, error is estimated in width/sqrt(12)
198 // For future, error estimate should be from CscClusterUtilTool.
199
200 // ECC - Returns likelihood for matching xy segments
201 // - currently uses charge ratio, but should be expanded for timing.
202 double matchLikelihood(const Muon::MuonSegment& rsg, const Muon::MuonSegment& psg) const;
203
204 // pdf distribution function for signal events.
205 static double pdf_sig(const double x) ;
206
207 // pdf distribution function for background events.
208 static double pdf_bkg(const double x) ;
209
210 // Likelihood function = psig/(psig +pbkg)
211 static double qratio_like(const double pdf_sig, const double pdf_bkg) ;
212
213 bool isGood(const uint32_t stripHashId, const EventContext& ctx) const;
214 int stripStatusBit(const uint32_t stripHashId, const EventContext& ctx) const;
215};
216
217#endif
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::pair< std::vector< unsigned int >, bool > res
static Double_t rs
static Double_t s0
Property holding a SG store/key/clid from which a ReadHandle is made.
#define x
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
static double pdf_bkg(const double x)
void fit_segment(const ICscSegmentFinder::TrkClusters &clus, const Amg::Vector3D &lpos000, double &s0, double &s1, double &d0, double &d1, double &d01, double &chsq, double &time, double &dtime, double &zshift, const EventContext &ctx, int outlierLayer=-1) const
virtual StatusCode initialize()
bool unique_hits(ICscSegmentFinder::TrkClusters &fitclus, ICscSegmentFinder::Segments &segs) const
Method for checking whether three hit segments are already part of 4 hit segments.
Gaudi::Property< double > m_max_slope_r
Gaudi::Property< bool > m_IPconstraint
void add_2dseg2hits(ICscSegmentFinder::Segments &segs, ICscSegmentFinder::Segments &segs2, int layStat) const
void fit_detailCalcPart2(double q0, double q1, double q2, double q01, double q11, double q02, double &s0, double &s1, double &d0, double &d1, double &d01, double &chsq) const
static double qratio_like(const double pdf_sig, const double pdf_bkg)
SG::ReadCondHandleKey< CscCondDbData > m_readKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Gaudi::Property< double > m_max_slope_phi
Gaudi::Property< double > m_max_chisquare
std::unique_ptr< std::vector< std::unique_ptr< Muon::MuonSegment > > > getMuonSegments(Identifier eta_id, Identifier phi_id, ICscSegmentFinder::ChamberTrkClusters &eta_clus, ICscSegmentFinder::ChamberTrkClusters &phi_clus, const Amg::Vector3D &lpos000, const EventContext &ctx) const
double getDefaultError(Identifier id, bool measphi, const Muon::CscPrepData *prd, const EventContext &ctx) const
Gaudi::Property< double > m_max_chisquare_tight
Gaudi::Property< int > m_nunspoil
void fit_residual(const ICscSegmentFinder::TrkClusters &clus, const Amg::Vector3D &lpos000, unsigned int irclu, double &res, double &dres, const EventContext &ctx) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< bool > m_remove3Overlap
Muon::MuonSegment * build_segment(const ICscSegmentFinder::Segment &seg, bool measphi, Identifier chid, bool use2Lay, const EventContext &ctx) const
double matchLikelihood(const Muon::MuonSegment &rsg, const Muon::MuonSegment &psg) const
void find_2dseg3hit(bool measphi, int station, int eta, int phi, const ICscSegmentFinder::ChamberTrkClusters &clus, const Amg::Vector3D &lpos000, ICscSegmentFinder::Segments &segs, ICscSegmentFinder::Segments &segs4hit, double localPos, double localSlope, const EventContext &ctx) const
void find_2dsegments(bool measphi, int station, int eta, int phi, const ICscSegmentFinder::ChamberTrkClusters &clus, const Amg::Vector3D &lpos000, ICscSegmentFinder::Segments &segs, double localPos, double localSlope, const EventContext &ctx) const
void get2dSegments(Identifier eta_id, Identifier phi_id, ICscSegmentFinder::ChamberTrkClusters &eta_clus, ICscSegmentFinder::ChamberTrkClusters &phi_clus, ICscSegmentFinder::Segments &etasegs, ICscSegmentFinder::Segments &phisegs, const Amg::Vector3D &lpos000, const EventContext &ctx, int etaStat=0, int phiStat=0) const
void fit_rio_residual(const Trk::PlaneSurface &ssrf, bool dump, const ICscSegmentFinder::RioList &clus, unsigned int irclu, double &res, double &dres, double &rs, double &drs) const
Gaudi::Property< bool > m_remove4Overlap
void fit_rio_segment(const Trk::PlaneSurface &ssrf, bool dump, const ICscSegmentFinder::RioList &clus, double &s0, double &s1, double &d0, double &d1, double &d01, double &chsq, double &zshift) const
Gaudi::Property< double > m_IPerror
int stripStatusBit(const uint32_t stripHashId, const EventContext &ctx) const
void spoiled_count(const ICscSegmentFinder::RioList &rios, double threshold, int &nspoil, int &nunspoil)
ToolHandle< Muon::ICscClusterOnTrackCreator > m_rotCreator
void getRios(const ICscSegmentFinder::Segment &seg, ICscSegmentFinder::MbaseList *prios, bool measphi, const EventContext &ctx) const
bool isGood(const uint32_t stripHashId, const EventContext &ctx) const
Gaudi::Property< bool > m_x5data
Gaudi::Property< double > m_fitsegment_tantheta_tolerance
Muon::MuonSegmentCombination * get4dMuonSegmentCombination(Identifier eta_id, Identifier phi_id, ICscSegmentFinder::ChamberTrkClusters &eta_clus, ICscSegmentFinder::ChamberTrkClusters &phi_clus, const Amg::Vector3D &lpos000, const EventContext &ctx) const
virtual ~CscSegmentUtilTool()=default
Gaudi::Property< bool > m_allEtaPhiMatches
Gaudi::Property< double > m_min_xylike
Gaudi::Property< double > m_max_chisquare_loose
static double pdf_sig(const double x)
void add_2dsegments(ICscSegmentFinder::Segments &segs4, ICscSegmentFinder::Segments &segs3) const
Adds 3-hit segments to 4-hit segments.
Gaudi::Property< bool > m_zshift
Gaudi::Property< bool > m_TightenChi2
Gaudi::Property< unsigned int > m_max_seg_per_chamber
Gaudi::Property< float > m_cluster_error_scaler
void find_2dseg2hit(bool measphi, int station, int eta, int phi, int layStat, const ICscSegmentFinder::ChamberTrkClusters &clus, const Amg::Vector3D &lpos000, ICscSegmentFinder::Segments &segs, double localPos, double localSlope, const EventContext &ctx) const
Muon::MuonSegment * make_4dMuonSegment(const Muon::MuonSegment &rsg, const Muon::MuonSegment &psg, bool use2LaySegsEta, bool use2LaySegsPhi) const
CscSegmentUtilTool(const std::string &type, const std::string &name, const IInterface *parent)
Muon::MuonSegmentCombination * get2dMuonSegmentCombination(Identifier eta_id, Identifier phi_id, ICscSegmentFinder::ChamberTrkClusters &eta_clus, ICscSegmentFinder::ChamberTrkClusters &phi_clus, const Amg::Vector3D &lpos000, const EventContext &ctx, int etaStat=0, int phiStat=0) const
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
void fit_detailCalcPart1(const ICscSegmentFinder::TrkClusters &clus, const Amg::Vector3D &lpos000, double &s0, double &s1, double &d0, double &d1, double &d01, double &chsq, bool &measphi, double &time, double &dtime, double &zshift, bool IsSlopeGive, int outlierHitLayer, const EventContext &ctx) const
Gaudi::Property< int > m_max_3hitseg_sharehit
int find_outlier_cluster(const ICscSegmentFinder::TrkClusters &clus, const Amg::Vector3D &lpos000, double &returned_chsq, const EventContext &ctx) const
DataVector< const Trk::MeasurementBase > MbaseList
std::vector< Cluster > ChamberTrkClusters[4]
std::vector< Segment > Segments
std::vector< const Trk::RIO_OnTrack * > RioList
std::vector< Cluster > TrkClusters
Class representing clusters from the CSC.
Definition CscPrepData.h:39
Class to hold a set of MuonSegments belonging together.
This is the common class for 3D segments used in the muon spectrometer.
Property holding a SG store/key/clid from which a ReadHandle is made.
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
Eigen::Matrix< double, 3, 1 > Vector3D
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Ensure that the ATLAS eigen extensions are properly loaded.
-event-from-file