7 #include "GaudiKernel/IDataProviderSvc.h"
8 #include "GaudiKernel/SmartDataPtr.h"
19 declareInterface<IMuTagAmbiguitySolverTool>(
this);
36 return StatusCode::SUCCESS;
40 const EventContext& ctx, std::vector<MuonCombined::MuonSegmentInfo> mtos)
const {
43 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
44 ATH_MSG_DEBUG(
" index " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer " << mtos[ns1].
track <<
" stationLayer "
45 << mtos[ns1].stationLayer <<
" selected " << mtos[ns1].selected);
47 if (mtos[ns1].selected == 2)
continue;
48 for (
unsigned int ns2 = ns1 + 1; ns2 < mtos.size(); ns2++) {
54 for (
unsigned int ns2 = ns1; ns2 < mtos.size(); ns2++) {
56 mtos[ns2].nsegments = nsegments;
57 mtos[ns2].selected = 2;
59 ATH_MSG_DEBUG(
" Updated index " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer " << mtos[ns1].
track
60 <<
" stationLayer " << mtos[ns1].stationLayer <<
" selected " << mtos[ns1].selected);
64 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
65 if (mtos[ns1].selected == 2) mtos[ns1].selected = 1;
66 if (mtos[ns1].nsegments == 1 && mtos[ns1].stationLayer == 21) {
67 mtos[ns1].selected = 0;
68 mtos[ns1].nsegments = 0;
73 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
74 ATH_MSG_DEBUG(
" First pass index " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer " << mtos[ns1].
track
75 <<
" stationLayer " << mtos[ns1].stationLayer <<
" selected " << mtos[ns1].selected);
77 for (
unsigned int ns2 = ns1 + 1; ns2 < mtos.size(); ns2++) {
79 double R1 = std::abs(mtos[ns1].pullCY *
Rseg(mtos[ns1].nsegments));
80 double R2 = std::abs(mtos[ns2].pullCY *
Rseg(mtos[ns2].nsegments));
81 ATH_MSG_DEBUG(
" Ambiguous segment at index " << ns1 <<
" and " << ns2);
83 mtos[ns1].selected = 0;
84 mtos[ns1].nsegments = 0;
86 mtos[ns2].selected = 0;
87 mtos[ns2].nsegments = 0;
94 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
96 if (mtos[ns1].selected == 0) nsegments = 0;
97 if (mtos[ns1].selected == 2)
continue;
98 for (
unsigned int ns2 = ns1 + 1; ns2 < mtos.size(); ns2++) {
100 if (mtos[ns2].selected != 0) nsegments++;
102 for (
unsigned int ns2 = ns1; ns2 < mtos.size(); ns2++) {
103 if (mtos[ns1].
track != mtos[ns2].
track)
break;
104 mtos[ns2].nsegments = nsegments;
105 mtos[ns2].selected = 2;
107 ATH_MSG_DEBUG(
" Second pass index " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer " << mtos[ns1].
track
108 <<
" stationLayer " << mtos[ns1].stationLayer <<
" selected " << mtos[ns1].selected);
113 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
114 if (mtos[ns1].selected == 2) mtos[ns1].selected = 1;
115 if (mtos[ns1].nsegments == 1 && mtos[ns1].stationLayer == 21) {
116 mtos[ns1].selected = 0;
117 mtos[ns1].nsegments = 0;
118 ATH_MSG_DEBUG(
" DROP CSC index " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer " << mtos[ns1].
track
119 <<
" stationLayer" << mtos[ns1].stationLayer <<
" selected " << mtos[ns1].selected);
124 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
125 if (mtos[ns1].nsegments == 1 && mtos[ns1].nholes > 2) {
126 mtos[ns1].selected = 0;
127 mtos[ns1].nsegments = 0;
128 ATH_MSG_DEBUG(
" DROP HOLES index " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer " << mtos[ns1].
track
129 <<
" stationLayer" << mtos[ns1].stationLayer <<
" selected " << mtos[ns1].selected);
135 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
136 if (mtos[ns1].nsegments == 1 && mtos[ns1].minimumPullPhi > 3 && mtos[ns1].hasPhi > 0) {
137 mtos[ns1].selected = 0;
138 mtos[ns1].nsegments = 0;
139 ATH_MSG_DEBUG(
" DROP MatchPhi index " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer " << mtos[ns1].
track
140 <<
" stationLayer" << mtos[ns1].stationLayer <<
" selected " << mtos[ns1].selected);
145 int multiplicity = mtos.size();
148 if (multiplicity > 50) {
149 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
150 if (mtos[ns1].nholes > 1) {
151 mtos[ns1].selected = 0;
152 mtos[ns1].nsegments = 0;
153 ATH_MSG_DEBUG(
" DROP multiplicity 50 index " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer "
154 << mtos[ns1].
track <<
" stationLayer" << mtos[ns1].stationLayer <<
" selected "
155 << mtos[ns1].selected);
158 }
else if (multiplicity > 30) {
159 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
160 if (mtos[ns1].nholes > 2) {
161 mtos[ns1].selected = 0;
162 mtos[ns1].nsegments = 0;
163 ATH_MSG_DEBUG(
" DROP multiplicity 30 index " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer "
164 << mtos[ns1].
track <<
" stationLayer" << mtos[ns1].stationLayer <<
" selected "
165 << mtos[ns1].selected);
171 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
172 if (mtos[ns1].nsegments == 1 && mtos[ns1].nholes > 0 && mtos[ns1].singleML == 1) {
173 mtos[ns1].selected = 0;
174 mtos[ns1].nsegments = 0;
175 ATH_MSG_DEBUG(
" DROP single multilayers single tag " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer "
176 << mtos[ns1].
track <<
" stationLayer" << mtos[ns1].stationLayer
177 <<
" selected " << mtos[ns1].selected);
183 double pTmax(10000.);
184 double pTcut =
pTmin;
185 if (multiplicity > 100)
187 else if (multiplicity < 10)
190 pTcut = 2 * ((pTmax -
pTmin) / 90.) * multiplicity;
192 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
195 double OneOverP = std::abs(perigee->parameters()[
Trk::qOverP]);
197 if (OneOverP > 0.0) {
198 pT = sintheta / OneOverP;
200 pT = std::hypot(perigee->momentum()[
Amg::px], perigee->momentum()[
Amg::py]);
203 if (mtos[ns1].nsegments == 1 && mtos[ns1].singleML == 1) {
204 mtos[ns1].selected = 0;
205 mtos[ns1].nsegments = 0;
206 ATH_MSG_DEBUG(
" DROP single multilayers low pT " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer "
207 << mtos[ns1].
track <<
" stationLayer" << mtos[ns1].stationLayer
208 <<
" selected " << mtos[ns1].selected);
215 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
216 if (mtos[ns1].nsegments == 1 && mtos[ns1].stationLayer == 13) {
217 mtos[ns1].selected = 0;
218 mtos[ns1].nsegments = 0;
219 ATH_MSG_DEBUG(
" DROP single tag OuterEndcap " << ns1 <<
" nsegments " << mtos[ns1].nsegments <<
" track pointer "
220 << mtos[ns1].
track <<
" stationLayer" << mtos[ns1].stationLayer
221 <<
" selected " << mtos[ns1].selected);
226 std::vector<MuonCombined::MuonSegmentInfo> mtosOutput;
227 mtosOutput.reserve(mtos.size());
229 for (
unsigned int ns1 = 0; ns1 < mtos.size(); ns1++) {
230 if (mtos[ns1].nsegments > 0) { mtosOutput.push_back(std::move(mtos[ns1])); }
240 if (&seg1 == &seg2)
return 1;
247 if (st1 != st2)
return 0;
258 bool sectorOk =
false;
259 if (sector1 == sector2) sectorOk =
true;
260 if (std::abs(sector1 - sector2) == 1) sectorOk =
true;
261 if ((sector1 == 16 && sector2 == 1) || (sector1 == 1 && sector2 == 16)) sectorOk =
true;
286 if (compareSegments.intersectionSize > 0) {
290 msg(
MSG::VERBOSE) <<
" found overlapping segment pair: " << compareSegments.print(
result) << std::endl
302 const EventContext& ctx, std::vector<MuonCombined::MuonSegmentInfo> mtss)
const {
305 std::vector<MuonCombined::MuonSegmentInfo> outputMTSs;
306 std::vector<bool>
accept(mtss.size(),
true);
307 for (
unsigned int mts1 = 0; mts1 < mtss.size(); ++mts1) {
318 for (
unsigned int mts2 = mts1 + 1; mts2 < mtss.size(); ++mts2) {
328 if (st1 != st2)
continue;
342 double chi2mts1 = std::abs(mtss[mts1].pullCY);
343 double chi2mts2 = std::abs(mtss[mts2].pullCY);
344 ATH_MSG_DEBUG(
"segments in the same station with MatchLocY " << chi2mts1 <<
" and " << chi2mts2);
345 if (std::abs(chi2mts1) < std::abs(chi2mts2)) {
346 ATH_MSG_DEBUG(
"dropping mts " << mts2 <<
" since he has a larger MatchLocY: " << chi2mts2 <<
" vs " << chi2mts1);
349 if (std::abs(chi2mts1) > std::abs(chi2mts2)) {
350 ATH_MSG_DEBUG(
"dropping mts " << mts1 <<
" since he has a larger MatchLocY: " << chi2mts1 <<
" vs " << chi2mts2);
356 if (
accept[mts1]) outputMTSs.push_back(mtss[mts1]);
363 constexpr
float a_seg{3.61883f}, b_seg{20.4547f}, c_seg{1.f / 0.132675f}, d_seg{0.102262f};
364 return (a_seg / (1. +
std::exp(b_seg - nseg * c_seg)) + d_seg);