ATLAS Offline Software
Loading...
Searching...
No Matches
SiSpacePointsSeedMaker_LowMomentum.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// Implementation file for class SiSpacePointsSeedMaker_LowMomentum
8// (c) ATLAS Detector software
10// AlgTool used for TRT_DriftCircleOnTrack object production
12// Version 1.0 21/04/2004 I.Gavrilenko
14
16
17#include <cmath>
18
19#include <iomanip>
20#include <limits>
21#include <ostream>
22
24// Constructor
26
28(const std::string& t, const std::string& n, const IInterface* p)
29 : base_class(t, n, p)
30{
31}
32
34// Initialisation
36
38{
39 StatusCode sc = AlgTool::initialize();
40
42 ATH_CHECK(m_spacepointsSCT.initialize(m_sct));
44
45 // Get beam geometry
46 //
47 ATH_CHECK(m_beamSpotKey.initialize());
48
49 ATH_CHECK( m_fieldCondObjInputKey.initialize());
50
51 // PRD-to-track association (optional)
52 ATH_CHECK( m_prdToTrackMap.initialize( !m_prdToTrackMap.key().empty()));
53
54 // Build framework
55 //
57
58 // Get output print level
59 //
60 m_outputlevel = msg().level()-MSG::DEBUG;
61 if (m_outputlevel<=0) {
64 data.nprint=0;
65 dump(data, msg(MSG::DEBUG));
66 }
67
68 m_initialized = true;
69
70 return sc;
71}
72
74// Finalize
76
78{
79 return AlgTool::finalize();
80}
81
83// Initialize tool for new event
85
86void InDet::SiSpacePointsSeedMaker_LowMomentum::newEvent(const EventContext& ctx, EventData& data, int) const
87{
88 if (not data.initialized) initializeEventData(data);
89
90 data.trigger = false;
91 if (!m_pixel && !m_sct) return;
92 erase(data);
93 data.i_spforseed = data.l_spforseed.begin();
95
96 float irstep = 1./m_r_rstep;
97 int irmax = m_r_size-1;
98
100 const Trk::PRDtoTrackMap *prd_to_track_map_cptr = nullptr;
101 if (!m_prdToTrackMap.key().empty()) {
103 if (!prd_to_track_map.isValid()) {
104 ATH_MSG_ERROR("Failed to read PRD to track association map: " << m_prdToTrackMap.key());
105 }
106 prd_to_track_map_cptr = prd_to_track_map.cptr();
107 }
108
109 // Get pixels space points containers from store gate
110 //
111 if (m_pixel) {
112
114 if (spacepointsPixel.isValid()) {
115
116 for (const SpacePointCollection* spc: *spacepointsPixel) {
117 for (const Trk::SpacePoint* sp: *spc) {
118
119 float r = sp->r();
120 if (r<0. || r>=m_r_rmax) continue;
121 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
122
124
125 int ir = static_cast<int>(sps->radius()*irstep);
126 if (ir>irmax) ir = irmax;
127 data.r_Sorted[ir].push_back(sps);
128 ++data.r_map[ir];
129 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
130 ++data.ns;
131 }
132 }
133 }
134 }
135
136 // Get sct space points containers from store gate
137 //
138 if (m_sct) {
139
141 if (spacepointsSCT.isValid()) {
142
143 for (const SpacePointCollection* spc: *spacepointsSCT) {
144 for (const Trk::SpacePoint* sp: *spc) {
145
146 float r = sp->r();
147 if (r<0. || r>=m_r_rmax) continue;
148 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
149
151
152 int ir = static_cast<int>(sps->radius()*irstep);
153 if (ir>irmax) ir = irmax;
154 data.r_Sorted[ir].push_back(sps);
155 ++data.r_map[ir];
156 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
157 ++data.ns;
158 }
159 }
160 }
161 }
163}
164
166// Initialize tool for new region
168
170(const EventContext& ctx, EventData& data,
171 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT) const{
172 if (not data.initialized) initializeEventData(data);
173
174 data.trigger = false;
175 if (!m_pixel && !m_sct) return;
176 erase(data);
177 data.i_spforseed = data.l_spforseed.begin();
179
180 int irmax = m_r_size-1;
181 float irstep = 1.f/m_r_rstep;
182
183 SG::ReadHandle<Trk::PRDtoTrackMap> prd_to_track_map;
184 const Trk::PRDtoTrackMap *prd_to_track_map_cptr = nullptr;
185 if (!m_prdToTrackMap.key().empty()) {
187 if (!prd_to_track_map.isValid()) {
188 ATH_MSG_ERROR("Failed to read PRD to track association map: " << m_prdToTrackMap.key());
189 }
190 prd_to_track_map_cptr = prd_to_track_map.cptr();
191 }
192
193 // Get pixels space points containers from store gate
194 //
195 if (m_pixel && !vPixel.empty()) {
196
198 if (spacepointsPixel.isValid()) {
199 // Loop through all trigger collections
200 //
201 for (const IdentifierHash& l: vPixel) {
202 const auto *w = spacepointsPixel->indexFindPtr(l);
203 if (w==nullptr) continue;
204 for (const Trk::SpacePoint* sp: *w) {
205 float r = sp->r();
206 if (r<0. || r>=m_r_rmax) continue;
207 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
208
210
211 int ir = static_cast<int>(sps->radius()*irstep);
212 if (ir>irmax) ir = irmax;
213 data.r_Sorted[ir].push_back(sps);
214 ++data.r_map[ir];
215 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
216 ++data.ns;
217 }
218 }
219 }
220 }
221
222 // Get sct space points containers from store gate
223 //
224 if (m_sct && !vSCT.empty()) {
225
227 if (spacepointsSCT.isValid()) {
228 // Loop through all trigger collections
229 //
230 for (const IdentifierHash& l: vSCT) {
231 const auto *w = spacepointsSCT->indexFindPtr(l);
232 if (w==nullptr) continue;
233 for (const Trk::SpacePoint* sp: *w) {
234 float r = sp->r();
235 if (r<0. || r>=m_r_rmax) continue;
236 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
238 int ir = static_cast<int>(sps->radius()*irstep);
239 if (ir>irmax) ir = irmax;
240 data.r_Sorted[ir].push_back(sps);
241 ++data.r_map[ir];
242 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
243 ++data.ns;
244 }
245 }
246 }
247 }
249}
250
252// Initialize tool for new region
254
256(const EventContext& ctx, EventData& data,
257 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT,
258 const IRoiDescriptor&) const
259{
260 newRegion(ctx, data, vPixel, vSCT);
261}
262
264// Methods to initilize different strategies of seeds production
265// with two space points with or without vertex constraint
267
268void InDet::SiSpacePointsSeedMaker_LowMomentum::find2Sp(EventData& data, const std::list<Trk::Vertex>& lv) const
269{
270 if (not data.initialized) initializeEventData(data);
271
272 int mode = 0;
273 if (lv.begin()!=lv.end()) mode = 1;
274 bool newv = newVertices(data, lv);
275
276 if (newv || !data.state || data.nspoint!=2 || data.mode!=mode || data.nlist) {
277 data.i_seede = data.l_seeds.begin();
278 data.state = 1;
279 data.nspoint = 2;
280 data.nlist = 0;
281 data.mode = mode;
282 data.endlist = true;
283 data.fNmin = 0;
284 data.zMin = 0;
286 }
287 data.i_seed = data.l_seeds.begin();
288
289 if (m_outputlevel<=0) {
290 data.nprint=1;
291 dump(data, msg(MSG::DEBUG));
292 }
293}
294
296// Methods to initilize different strategies of seeds production
297// with three space points with or without vertex constraint
299
300void InDet::SiSpacePointsSeedMaker_LowMomentum::find3Sp(const EventContext& ctx, EventData& data, const std::list<Trk::Vertex>& lv) const
301{
302 if (not data.initialized) initializeEventData(data);
303
304 int mode = 2;
305 if (lv.begin()!=lv.end()) mode = 3;
306 bool newv = newVertices(data, lv);
307
308 if (newv || !data.state || data.nspoint!=3 || data.mode!=mode || data.nlist) {
309 data.i_seede = data.l_seeds.begin();
310 data.state = 1;
311 data.nspoint = 3;
312 data.nlist = 0;
313 data.mode = mode;
314 data.endlist = true;
315 data.fNmin = 0;
316 data.zMin = 0;
317 production3Sp(ctx, data);
318 }
319 data.i_seed = data.l_seeds.begin();
320
321 if (m_outputlevel<=0) {
322 data.nprint=1;
323 dump(data, msg(MSG::DEBUG));
324 }
325}
326
327void InDet::SiSpacePointsSeedMaker_LowMomentum::find3Sp(const EventContext& ctx, EventData& data, const std::list<Trk::Vertex>& lv, const double*) const
328{
329 find3Sp(ctx, data, lv);
330}
331
333// Methods to initilize different strategies of seeds production
334// with variable number space points with or without vertex constraint
335// Variable means (2,3,4,....) any number space points
337
338void InDet::SiSpacePointsSeedMaker_LowMomentum::findVSp(const EventContext& ctx, EventData& data, const std::list<Trk::Vertex>& lv) const
339{
340 if (not data.initialized) initializeEventData(data);
341
342 int mode = 5;
343 if (lv.begin()!=lv.end()) mode = 6;
344 bool newv = newVertices(data, lv);
345
346 if (newv || !data.state || data.nspoint!=4 || data.mode!=mode || data.nlist) {
347 data.i_seede = data.l_seeds.begin();
348 data.state = 1;
349 data.nspoint = 4;
350 data.nlist = 0;
351 data.mode = mode;
352 data.endlist = true;
353 data.fNmin = 0;
354 data.zMin = 0;
355 production3Sp(ctx, data);
356 }
357 data.i_seed = data.l_seeds.begin();
358
359 if (m_outputlevel<=0) {
360 data.nprint=1;
361 dump(data, msg(MSG::DEBUG));
362 }
363}
364
366// Dumps relevant information into the MsgStream
368
370{
371 if (not data.initialized) initializeEventData(data);
372
373 if (data.nprint) return dumpEvent(data, out);
374 return dumpConditions(data, out);
375}
376
378// Dumps conditions information into the MsgStream
380
382{
383 int n = 42-m_spacepointsPixel.key().size();
384 std::string s2; for (int i=0; i<n; ++i) s2.append(" "); s2.append("|");
385 n = 42-m_spacepointsSCT.key().size();
386 std::string s3; for (int i=0; i<n; ++i) s3.append(" "); s3.append("|");
387 n = 42-m_spacepointsOverlap.key().size();
388 std::string s4; for (int i=0; i<n; ++i) s4.append(" "); s4.append("|");
389 n = 42-m_beamSpotKey.key().size();
390 std::string s5; for (int i=0; i<n; ++i) s5.append(" "); s5.append("|");
391
392 out<<"|---------------------------------------------------------------------|"
393 <<endmsg;
394 out<<"| Pixel space points | "<<m_spacepointsPixel.key() <<s2
395 <<endmsg;
396 out<<"| SCT space points | "<<m_spacepointsSCT.key()<<s3
397 <<endmsg;
398 out<<"| Overlap space points | "<<m_spacepointsOverlap.key()<<s4
399 <<endmsg;
400 out<<"| BeamConditionsService | "<<m_beamSpotKey.key()<<s5
401 <<endmsg;
402 out<<"| usePixel | "
403 <<std::setw(12)<<m_pixel
404 <<" |"<<endmsg;
405 out<<"| useSCT | "
406 <<std::setw(12)<<m_sct
407 <<" |"<<endmsg;
408 out<<"| Use PRD-to-track assoc.?| "
409 <<std::setw(12)<< (!m_prdToTrackMap.key().empty() ? "yes" : "no ")
410 <<" |"<<endmsg;
411 out<<"| maxSize | "
412 <<std::setw(12)<<m_maxsize
413 <<" |"<<endmsg;
414 out<<"| maxSizeSP | "
415 <<std::setw(12)<<m_maxsizeSP
416 <<" |"<<endmsg;
417 out<<"| pTmin (mev) | "
418 <<std::setw(12)<<std::setprecision(5)<<m_ptmin
419 <<" |"<<endmsg;
420 out<<"| pTmax (mev) | "
421 <<std::setw(12)<<std::setprecision(5)<<m_ptmax
422 <<" |"<<endmsg;
423 out<<"| |eta| <= | "
424 <<std::setw(12)<<std::setprecision(5)<<m_etamax
425 <<" |"<<endmsg;
426 out<<"| max radius SP | "
427 <<std::setw(12)<<std::setprecision(5)<<m_r_rmax
428 <<" |"<<endmsg;
429 out<<"| radius step | "
430 <<std::setw(12)<<std::setprecision(5)<<m_r_rstep
431 <<" |"<<endmsg;
432 out<<"| min Z-vertex position | "
433 <<std::setw(12)<<std::setprecision(5)<<m_zmin
434 <<" |"<<endmsg;
435 out<<"| max Z-vertex position | "
436 <<std::setw(12)<<std::setprecision(5)<<m_zmax
437 <<" |"<<endmsg;
438 out<<"| min radius first SP(3) | "
439 <<std::setw(12)<<std::setprecision(5)<<m_r1min
440 <<" |"<<endmsg;
441 out<<"| min radius second SP(3) | "
442 <<std::setw(12)<<std::setprecision(5)<<m_r2min
443 <<" |"<<endmsg;
444 out<<"| min radius last SP(3) | "
445 <<std::setw(12)<<std::setprecision(5)<<m_r3min
446 <<" |"<<endmsg;
447 out<<"| max radius first SP(3) | "
448 <<std::setw(12)<<std::setprecision(4)<<m_r1max
449 <<" |"<<endmsg;
450 out<<"| max radius second SP(3) | "
451 <<std::setw(12)<<std::setprecision(5)<<m_r2max
452 <<" |"<<endmsg;
453 out<<"| max radius last SP(3) | "
454 <<std::setw(12)<<std::setprecision(5)<<m_r3max
455 <<" |"<<endmsg;
456 out<<"| min space points dR | "
457 <<std::setw(12)<<std::setprecision(5)<<m_drmin
458 <<" |"<<endmsg;
459 out<<"| max space points dR | "
460 <<std::setw(12)<<std::setprecision(5)<<m_drmax
461 <<" |"<<endmsg;
462 out<<"| max dZ impact | "
463 <<std::setw(12)<<std::setprecision(5)<<m_dzver
464 <<" |"<<endmsg;
465 out<<"| max dZ/dR impact | "
466 <<std::setw(12)<<std::setprecision(5)<<m_dzdrver
467 <<" |"<<endmsg;
468 out<<"| max impact | "
469 <<std::setw(12)<<std::setprecision(5)<<m_diver
470 <<" |"<<endmsg;
471 out<<"|---------------------------------------------------------------------|"
472 <<endmsg;
473 out<<"| Beam X center | "
474 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[0]
475 <<" |"<<endmsg;
476 out<<"| Beam Y center | "
477 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[0]
478 <<" |"<<endmsg;
479 out<<"| Beam Z center | "
480 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[0]
481 <<" |"<<endmsg;
482 out<<"| Beam X-axis direction | "
483 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[1]
484 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[2]
485 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[3]
486 <<" |"<<endmsg;
487 out<<"| Beam Y-axis direction | "
488 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[1]
489 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[2]
490 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[3]
491 <<" |"<<endmsg;
492 out<<"| Beam Z-axis direction | "
493 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[1]
494 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[2]
495 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[3]
496 <<" |"<<endmsg;
497 out<<"|---------------------------------------------------------------------|"
498 <<endmsg;
499 return out;
500}
501
503// Dumps event information into the MsgStream
505
507{
508 out<<"|---------------------------------------------------------------------|"
509 <<endmsg;
510 out<<"| data.ns | "
511 <<std::setw(12)<<data.ns
512 <<" |"<<endmsg;
513 out<<"| data.nsaz | "
514 <<std::setw(12)<<data.nsaz
515 <<" |"<<endmsg;
516 out<<"| seeds | "
517 <<std::setw(12)<<data.l_seeds.size()
518 <<" |"<<endmsg;
519 out<<"|---------------------------------------------------------------------|"
520 <<endmsg;
521 return out;
522}
523
525// Find next set space points
527
529{
530 if (data.endlist) return;
531
532 data.i_seede = data.l_seeds.begin();
533 if (data.mode==0 || data.mode==1) {
535 } else if (data.mode==2 || data.mode==3) {
536 production3Sp(ctx, data);
537 } else if (data.mode==5 || data.mode==6) {
538 production3Sp(ctx, data);
539 }
540
541 data.i_seed = data.l_seeds.begin();
542 ++data.nlist;
543}
544
546// New and old list vertices comparison
548
550{
551 unsigned int s1 = data.l_vertex.size();
552 unsigned int s2 = lV.size();
553
554 if (s1==0 && s2==0) return false;
555
556 data.l_vertex.clear();
557
558 for (const Trk::Vertex& v : lV) {
559 data.l_vertex.insert(static_cast<float>(v.position().z()));
560 }
561 return false;
562}
563
565// Initiate frame work for seed generator
567
569{
570 m_ptmin = std::max( std::abs(m_ptmin), float(50.*m_fieldScale));
571 m_iptmax = 1.f/std::abs(m_ptmax);
572 m_iptmin = 1.f/std::abs(m_ptmin);
573 m_etamax = std::abs(m_etamax);
574 m_dzdrmax = 1.f/std::tan(2.f*std::atan(std::exp(-m_etamax)));
577
578 // Build radius sorted containers
579 //
580 m_r_size = static_cast<int>((m_r_rmax+.1f)/m_r_rstep);
581
582 // Build radius-azimuthal sorted containers
583 //
584 constexpr float pi2 = 2.*M_PI;
585 const int NFmax = SizeRF;
586 const float sFmax = static_cast<float>(NFmax )/pi2;
587 const float sFmin = 100./60.;
588 m_sF = m_ptmin/m_fieldScale /60.f;
589 if (m_sF > sFmax ) m_sF = sFmax;
590 else if (m_sF < sFmin) m_sF = sFmin;
591 m_fNmax = static_cast<int>(pi2*m_sF);
592 if (m_fNmax >=NFmax) m_fNmax = NFmax-1;
593
594 // Build maps for radius-azimuthal-Z sorted collections
595 //
596 for (int f=0; f<=m_fNmax; ++f) {
597 int fb = f-1; if (fb<0 ) fb=m_fNmax;
598 int ft = f+1; if (ft>m_fNmax) ft=0;
599
600 // For each azimuthal region loop through all Z regions
601 //
602 for (int z=0; z<SizeZ; ++z) {
603 int a = f *SizeZ+z;
604 int b = fb*SizeZ+z;
605 int c = ft*SizeZ+z;
606 m_rfz_b [a] = 3; m_rfz_t [a] = 3;
607 m_rfz_ib[a][0] = a; m_rfz_it[a][0] = a;
608 m_rfz_ib[a][1] = b; m_rfz_it[a][1] = b;
609 m_rfz_ib[a][2] = c; m_rfz_it[a][2] = c;
610 if (z==5) {
611 m_rfz_t [a] = 9;
612 m_rfz_it[a][3] = a+1;
613 m_rfz_it[a][4] = b+1;
614 m_rfz_it[a][5] = c+1;
615 m_rfz_it[a][6] = a-1;
616 m_rfz_it[a][7] = b-1;
617 m_rfz_it[a][8] = c-1;
618 } else if (z> 5) {
619 m_rfz_b [a] = 6;
620 m_rfz_ib[a][3] = a-1;
621 m_rfz_ib[a][4] = b-1;
622 m_rfz_ib[a][5] = c-1;
623 if (z<10) {
624 m_rfz_t [a] = 6;
625 m_rfz_it[a][3] = a+1;
626 m_rfz_it[a][4] = b+1;
627 m_rfz_it[a][5] = c+1;
628 }
629 } else {
630 m_rfz_b [a] = 6;
631 m_rfz_ib[a][3] = a+1;
632 m_rfz_ib[a][4] = b+1;
633 m_rfz_ib[a][5] = c+1;
634 if (z>0) {
635 m_rfz_t [a] = 6;
636 m_rfz_it[a][3] = a-1;
637 m_rfz_it[a][4] = b-1;
638 m_rfz_it[a][5] = c-1;
639 }
640 }
641 if (z==3) {
642 m_rfz_b[a] = 9;
643 m_rfz_ib[a][6] = a+2;
644 m_rfz_ib[a][7] = b+2;
645 m_rfz_ib[a][8] = c+2;
646 } else if (z==7) {
647 m_rfz_b[a] = 9;
648 m_rfz_ib[a][6] = a-2;
649 m_rfz_ib[a][7] = b-2;
650 m_rfz_ib[a][8] = c-2;
651 }
652 }
653 }
654}
655
657// Initiate beam frame work for seed generator
659
661{
663
664 const Amg::Vector3D &cb = beamSpotHandle->beamPos();
665 double tx = std::tan(beamSpotHandle->beamTilt(0));
666 double ty = std::tan(beamSpotHandle->beamTilt(1));
667
668 double ph = std::atan2(ty,tx);
669 double th = std::acos(1.f/std::sqrt(1.f+tx*tx+ty*ty));
670 double sint = std::sin(th);
671 double cost = std::cos(th);
672 double sinp = std::sin(ph);
673 double cosp = std::cos(ph);
674
675 data.xbeam[0] = static_cast<float>(cb.x());
676 data.xbeam[1] = static_cast<float>(cost*cosp*cosp+sinp*sinp);
677 data.xbeam[2] = static_cast<float>(cost*sinp*cosp-sinp*cosp);
678 data.xbeam[3] = -static_cast<float>(sint*cosp );
679
680 data.ybeam[0] = static_cast<float>(cb.y());
681 data.ybeam[1] = static_cast<float>(cost*cosp*sinp-sinp*cosp);
682 data.ybeam[2] = static_cast<float>(cost*sinp*sinp+cosp*cosp);
683 data.ybeam[3] = -static_cast<float>(sint*sinp );
684
685 data.zbeam[0] = static_cast<float>(cb.z());
686 data.zbeam[1] = static_cast<float>(sint*cosp);
687 data.zbeam[2] = static_cast<float>(sint*sinp);
688 data.zbeam[3] = static_cast<float>(cost);
689}
690
692// Initiate beam frame work for seed generator
694
696(EventData& data, const Trk::SpacePoint*const& sp, float* r)
697{
698 r[0] = static_cast<float>(sp->globalPosition().x())-data.xbeam[0];
699 r[1] = static_cast<float>(sp->globalPosition().y())-data.ybeam[0];
700 r[2] = static_cast<float>(sp->globalPosition().z())-data.zbeam[0];
701}
702
704// Initiate space points seed maker
706
708{
709 constexpr float pi2 = 2.*M_PI;
710
711 for (int i=0; i<m_r_size; ++i) {
712
713 if (!data.r_map[i]) continue;
714
715 for (InDet::SiSpacePointForSeed* r : data.r_Sorted[i]) {
716
717 // Azimuthal angle sort
718 //
719 float F = r->phi();
720 if (F<0.) F+=pi2;
721
722 int f = static_cast<int>(F*m_sF);
723 if (f < 0) f = m_fNmax;
724 else if (f > m_fNmax) f = 0;
725
726 int z;
727 float Z = r->z();
728
729 // Azimuthal angle and Z-coordinate sort
730 //
731 if (Z>0.) {
732 Z< 250.?z=5:Z< 450.?z=6:Z< 925.?z=7:Z< 1400.?z=8:Z< 2500.?z=9:z=10;
733 } else {
734 Z>-250.?z=5:Z>-450.?z=4:Z>-925.?z=3:Z>-1400.?z=2:Z>-2500.?z=1:z= 0;
735 }
736 int n = f*SizeZ+z;
737 ++data.nsaz;
738 data.rfz_Sorted[n].push_back(r);
739 if (!data.rfz_map[n]++) data.rfz_index[data.nrfz++] = n;
740 }
741 data.r_Sorted[i].clear();
742 data.r_map[i] = 0;
743 }
744 data.nr = 0;
745 data.state = 0;
746}
747
749// Erase space point information
751
753{
754 for (int i=0; i!=data.nr; ++i) {
755 int n = data.r_index[i];
756 data.r_map[n] = 0;
757 data.r_Sorted[n].clear();
758 }
759
760 for (int i=0; i!=data.nrfz; ++i) {
761 int n = data.rfz_index[i];
762 data.rfz_map[n] = 0;
763 data.rfz_Sorted[n].clear();
764 }
765
766 data.state = 0;
767 data.ns = 0;
768 data.nsaz = 0;
769 data.nr = 0;
770 data.nrfz = 0;
771}
772
774// 2 space points seeds production
776
781
783// Production 3 space points seeds (new version)
785
787{
788 if (data.nsaz<3) return;
789
790 float K = 0.;
791 double f[3], gP[3] ={10.,10.,0.};
792
793 MagField::AtlasFieldCache fieldCache;
794
795 // Get field cache object
797 const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
798 if (fieldCondObj == nullptr) {
799 ATH_MSG_ERROR("SiSpacePointsSeedMaker_LowMomentum: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCondObjInputKey.key());
800 return;
801 }
802 fieldCondObj->getInitializedCache (fieldCache);
803
804 if (fieldCache.solenoidOn()) {
805 fieldCache.getFieldZR(gP, f);
806
807 K = 2./(300.*f[2]);
808 } else {
809 K = 2./(300.* 5. );
810 }
811
812 const int ZI[SizeZ]= {5,6,7,8,9,10,4,3,2,1,0};
813 std::vector<InDet::SiSpacePointForSeed*>::iterator rt[9],rte[9],rb[9],rbe[9];
814 int nseed = 0;
815
816 // Loop thorugh all azimuthal regions
817 //
818 for (int f=data.fNmin; f<=m_fNmax; ++f) {
819 // For each azimuthal region loop through all Z regions
820 //
821 int z = 0;
822 if (!data.endlist) z = data.zMin;
823
824 for (; z<SizeZ; ++z) {
825 int a = f *SizeZ+ZI[z];
826 if (!data.rfz_map[a]) continue;
827 int NB = 0, NT = 0;
828 for (int i=0; i!=m_rfz_b[a]; ++i) {
829 int an = m_rfz_ib[a][i];
830 if (!data.rfz_map[an]) continue;
831 rb [NB] = data.rfz_Sorted[an].begin();
832 rbe[NB++] = data.rfz_Sorted[an].end();
833 }
834 for (int i=0; i!=m_rfz_t[a]; ++i) {
835 int an = m_rfz_it[a][i];
836 if (!data.rfz_map[an]) continue;
837 rt [NT] = data.rfz_Sorted[an].begin();
838 rte[NT++] = data.rfz_Sorted[an].end();
839 }
840 production3Sp(data, rb, rbe, rt, rte, NB, NT, nseed, K);
841 if (!data.endlist) {
842 data.fNmin=f;
843 data.zMin = z;
844 return;
845 }
846 }
847 }
848 data.endlist = true;
849}
850
852// Production 3 space points seeds (new version)
854
857 std::vector<InDet::SiSpacePointForSeed*>::iterator* rb ,
858 std::vector<InDet::SiSpacePointForSeed*>::iterator* rbe,
859 std::vector<InDet::SiSpacePointForSeed*>::iterator* rt ,
860 std::vector<InDet::SiSpacePointForSeed*>::iterator* rte,
861 int NB, int NT, int& nseed, float K) const
862{
863
864 const float COF = 134*.07*9.;
865 const float COFP = 134*.2*9.;
866
867 std::vector<InDet::SiSpacePointForSeed*>::iterator r0=rb[0],r;
868 if (!data.endlist) {
869 r0 = data.rMin;
870 data.endlist = true;
871 }
872
873 // Loop through all trigger space points
874 //
875 for (; r0!=rbe[0]; ++r0) {
876 data.nOneSeeds = 0;
877 data.mapOneSeeds.erase(data.mapOneSeeds.begin(), data.mapOneSeeds.end());
878
879 float R = (*r0)->radius();
880 if (R<m_r2min) continue;
881 if (R>m_r2max) break;
882
883 bool pix = true;
884 if ((*r0)->spacepoint->clusterList().second) pix = false;
885 const Trk::Surface* sur0 = (*r0)->sur();
886 float X = (*r0)->x();
887 float Y = (*r0)->y();
888 float Z = (*r0)->z();
889 int Nb = 0;
890
891 // Bottom links production
892 //
893 for (int i=0; i!=NB; ++i) {
894 for (r=rb[i]; r!=rbe[i]; ++r) {
895 float Rb =(*r)->radius();
896 if (Rb<m_r1min) {
897 rb[i]=r;
898 continue;
899 }
900 if (Rb>m_r1max) break;
901
902 float dR = R-Rb;
903 if (dR<m_drmin) break;
904
905 if (dR>m_drmax || (*r)->sur()==sur0) continue;
906
907 if ( !pix && !(*r)->spacepoint->clusterList().second) continue;
908
909 float dx = X-(*r)->x();
910 float dy = Y-(*r)->y();
911 float dZ = Z-(*r)->z();
912 data.Tz[Nb] = dZ/std::sqrt(dx*dx+dy*dy);
913 if (data.Tz[Nb]<m_dzdrmin || data.Tz[Nb]>m_dzdrmax) continue;
914 data.Zo[Nb] = Z-R*data.Tz[Nb];
915
916 // Comparison with vertices Z coordinates
917 //
918 if (!isZCompatible(data, data.Zo[Nb], Rb, data.Tz[Nb])) continue;
919 data.SP[Nb] = (*r);
920 if (++Nb==m_maxsizeSP) goto breakb;
921 }
922 }
923 breakb:
924 if (!Nb || Nb==m_maxsizeSP) continue;
925 int Nt = Nb;
926
927 // Top links production
928 //
929 for (int i=0; i!=NT; ++i) {
930 for (r=rt[i]; r!=rte[i]; ++r) {
931 float Rt =(*r)->radius();
932 float dR = Rt-R;
933 if (dR<m_drmin || Rt<m_r3min) {
934 rt[i]=r;
935 continue;
936 }
937 if (Rt>m_r3max || dR>m_drmax) break;
938
939 if ((*r)->sur()==sur0) continue;
940
941 float dx = X-(*r)->x();
942 float dy = Y-(*r)->y();
943 float dZ = (*r)->z()-Z;
944 data.Tz[Nt] = dZ/std::sqrt(dx*dx+dy*dy);
945 if (data.Tz[Nt]<m_dzdrmin || data.Tz[Nt]>m_dzdrmax) continue;
946 data.Zo[Nt] = Z-R*data.Tz[Nt];
947
948 // Comparison with vertices Z coordinates
949 //
950 if (!isZCompatible(data, data.Zo[Nt], Rt, data.Tz[Nt])) continue;
951 data.SP[Nt] = (*r);
952 if (++Nt==m_maxsizeSP) goto breakt;
953 }
954 }
955
956 breakt:
957 if (!(Nt-Nb)) continue;
958
959 float covr0 = (*r0)->covr ();
960 float covz0 = (*r0)->covz ();
961 float ax = X/R;
962 float ay = Y/R;
963
964 for (int i=0; i!=Nt; ++i) {
965 float dx = data.SP[i]->x()-X;
966 float dy = data.SP[i]->y()-Y;
967 float dz = data.SP[i]->z()-Z;
968 float x = dx*ax+dy*ay;
969 float y =-dx*ay+dy*ax;
970 float r2 = 1.f/(x*x+y*y);
971 float dr = std::sqrt(r2);
972
973 i < Nb ? data.Tz[i] = -dz*dr : data.Tz[i] = dz*dr;
974
975 data.U [i] = x*r2;
976 data.V [i] = y*r2;
977 data.Er[i] = (covz0+data.SP[i]->covz()+data.Tz[i]*data.Tz[i]*(covr0+data.SP[i]->covr()))*r2;
978 data.R [i] = dr;
979 }
980
981 // Three space points comparison
982 //
983 for (int b=Nb-1; b>=0; --b) {
984 float SA = 1.f+data.Tz[b]*data.Tz[b];
985 for (int t=Nb; t!=Nt; ++t) {
986 float cof = COF;
987 if (!data.SP[t]->spacepoint->clusterList().second) cof = COFP;
988
989 float Ts = .5f*(data.Tz[b]+data.Tz[t]);
990 float dT = data.Tz[b]-data.Tz[t];
991 dT = dT*dT-data.Er[b]-data.Er[t]-2.*data.R[b]*data.R[t]*(Ts*Ts*covr0+covz0);
992
993 if (dT > 0. && dT > (m_iptmin*m_iptmin)*cof*SA) continue;
994 float dU = data.U[t]-data.U[b];
995 if (dU == 0.) continue;
996 float A = (data.V[t]-data.V[b])/dU;
997 float B = data.V[t]-A*data.U[t];
998 float S2 = 1.f+A*A;
999 float S = std::sqrt(S2);
1000 float BK = std::abs(B*K);
1001 if (BK > m_iptmin*S || BK < m_iptmax*S) continue; // Momentum cut
1002 if (dT > 0. && dT > (BK*BK/S2)*cof*SA) continue; // Polar angle cut
1003
1004 float Im = std::abs((A-B*R)*R);
1005 if (Im > m_diver) continue;
1006
1007 newOneSeed(data, data.SP[b]->spacepoint,(*r0)->spacepoint,data.SP[t]->spacepoint,data.Zo[b],Im);
1008 }
1009 }
1010 nseed += data.mapOneSeeds.size();
1011 fillSeeds(data);
1012 if (nseed>=m_maxsize) {
1013 data.endlist=false;
1014 ++r0;
1015 data.rMin = r0;
1016 return;
1017 }
1018 }
1019}
1020
1022// New 3 space points seeds from one space points
1024
1026(EventData& data,
1027 const Trk::SpacePoint*& p1,const Trk::SpacePoint*& p2,
1028 const Trk::SpacePoint*& p3,const float& z,const float& q) const
1029{
1030 if (data.nOneSeeds < m_maxOneSize) {
1031 data.OneSeeds[data.nOneSeeds].erase();
1032 data.OneSeeds[data.nOneSeeds].add(p1);
1033 data.OneSeeds[data.nOneSeeds].add(p2);
1034 data.OneSeeds[data.nOneSeeds].add(p3);
1035 data.OneSeeds[data.nOneSeeds].setZVertex(static_cast<double>(z));
1036 data.mapOneSeeds.insert(std::make_pair(q, &(data.OneSeeds[data.nOneSeeds])));
1037 ++data.nOneSeeds;
1038 } else {
1039 std::multimap<float,InDet::SiSpacePointsSeed*>::reverse_iterator
1040 l = data.mapOneSeeds.rbegin();
1041 if ((*l).first <= q) return;
1042
1043 InDet::SiSpacePointsSeed* s = (*l).second;
1044 s->erase ( );
1045 s->add (p1);
1046 s->add (p2);
1047 s->add (p3);
1048 s->setZVertex(static_cast<double>(z));
1049 std::multimap<float,InDet::SiSpacePointsSeed*>::iterator
1050 i = data.mapOneSeeds.insert(std::make_pair(q,s));
1051 for (++i; i!=data.mapOneSeeds.end(); ++i) {
1052 if ((*i).second==s) {
1053 data.mapOneSeeds.erase(i);
1054 return;
1055 }
1056 }
1057 }
1058}
1059
1061{
1062 if (not data.initialized) initializeEventData(data);
1063
1064 if (data.i_seed==data.i_seede) {
1065 findNext(ctx, data);
1066 //cppcheck-suppress identicalInnerCondition
1067 if (data.i_seed==data.i_seede) return nullptr;
1068 }
1069 return &(*data.i_seed++);
1070}
1071
1073(EventData& data, float& Zv, float& R, float& T) const
1074{
1075 if (Zv < m_zmin || Zv > m_zmax) return false;
1076
1077 if (data.l_vertex.empty()) return true;
1078
1079 float dZmin = std::numeric_limits<float>::max();
1080 for (const float& v : data.l_vertex) {
1081 float dZ = std::abs(v-Zv);
1082 if (dZ<dZmin) dZmin=dZ;
1083 }
1084 return dZmin < (m_dzver+m_dzdrver*R)*std::sqrt(1.f+T*T);
1085}
1086
1088// New space point for seeds
1090
1092(EventData& data, const Trk::SpacePoint*const& sp)
1093{
1094 InDet::SiSpacePointForSeed* sps = nullptr;
1095
1096 float r[3];
1098
1099 if (data.i_spforseed!=data.l_spforseed.end()) {
1100 sps = &(*data.i_spforseed++);
1101 sps->set(sp, r);
1102 } else {
1103 data.l_spforseed.emplace_back(sp, r);
1104 sps = &(data.l_spforseed.back());
1105 data.i_spforseed = data.l_spforseed.end();
1106 }
1107
1108 return sps;
1109}
1110
1112// New 2 space points seeds
1114
1116(EventData& data,
1117 const Trk::SpacePoint*& p1,const Trk::SpacePoint*& p2,
1118 const float& z)
1119{
1120 if (data.i_seede!=data.l_seeds.end()) {
1121 InDet::SiSpacePointsSeed* s = &(*data.i_seede++);
1122 s->erase();
1123 s->add(p1);
1124 s->add(p2);
1125 s->setZVertex(static_cast<double>(z));
1126 } else {
1127 data.l_seeds.emplace_back(p1, p2, z);
1128 data.i_seede = data.l_seeds.end();
1129 }
1130}
1131
1133// New 3 space points seeds
1135
1137(EventData& data,
1138 const Trk::SpacePoint*& p1,const Trk::SpacePoint*& p2,
1139 const Trk::SpacePoint*& p3,const float& z)
1140{
1141 if (data.i_seede!=data.l_seeds.end()) {
1142 InDet::SiSpacePointsSeed* s = &(*data.i_seede++);
1143 s->erase();
1144 s->add(p1);
1145 s->add(p2);
1146 s->add(p3);
1147 s->setZVertex(static_cast<double>(z));
1148 } else {
1149 data.l_seeds.emplace_back(p1, p2, p3, z);
1150 data.i_seede = data.l_seeds.end();
1151 }
1152}
1153
1155// Fill seeds
1157
1159{
1160 std::multimap<float,InDet::SiSpacePointsSeed*>::iterator
1161 l = data.mapOneSeeds.begin(),
1162 le = data.mapOneSeeds.end ();
1163
1164 for (; l!=le; ++l) {
1165 if (data.i_seede!=data.l_seeds.end()) {
1166 InDet::SiSpacePointsSeed* s = &(*data.i_seede++);
1167 *s = *(*l).second;
1168 } else {
1169 data.l_seeds.emplace_back(*(*l).second);
1170 data.i_seede = data.l_seeds.end();
1171 }
1172 }
1173}
1174
1176 data.initialize(EventData::ToolType::LowMomentum,
1179 0, // maxsize not used
1180 m_r_size,
1181 0, // sizeRF not used
1182 SizeRFZ,
1183 0, // sizeRFZV not used
1184 false); // checkEta not used
1185}
1186
1189
#define M_PI
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t sp
static Double_t a
static Double_t sc
#define F(x, y, z)
Definition MD5.cxx:112
struct TBPatternUnitContext S2
#define y
#define x
#define z
static const Attributes_t empty
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
Describes the API of the Region of Ineterest geometry.
This is a "hash" representation of an Identifier.
void set(const Trk::SpacePoint *, std::span< float const, 3 >)
MsgStream & dumpConditions(EventData &data, MsgStream &out) const
SG::ReadHandleKey< SpacePointOverlapCollection > m_spacepointsOverlap
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
static MsgStream & dumpEvent(EventData &data, MsgStream &out)
static SiSpacePointForSeed * newSpacePoint(EventData &data, const Trk::SpacePoint *const &)
SG::ReadHandleKey< SpacePointContainer > m_spacepointsSCT
SG::ReadHandleKey< SpacePointContainer > m_spacepointsPixel
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCondObjInputKey
virtual const SiSpacePointsSeed * next(const EventContext &ctx, EventData &data) const override
virtual void newRegion(const EventContext &ctx, EventData &data, const std::vector< IdentifierHash > &vPixel, const std::vector< IdentifierHash > &vSCT) const override
virtual void findVSp(const EventContext &ctx, EventData &data, const std::list< Trk::Vertex > &lv) const override
with variable number space points with or without vertex constraint Variable means (2,...
void production3Sp(const EventContext &ctx, EventData &data) const
virtual void find2Sp(EventData &data, const std::list< Trk::Vertex > &lv) const override
with two space points with or without vertex constraint
static void convertToBeamFrameWork(EventData &data, const Trk::SpacePoint *const &, float *)
virtual void newEvent(const EventContext &ctx, EventData &data, int iteration) const override
virtual void find3Sp(const EventContext &ctx, EventData &data, const std::list< Trk::Vertex > &lv) const override
with three space points with or without vertex constraint
static bool newVertices(EventData &data, const std::list< Trk::Vertex > &)
void findNext(const EventContext &ctx, EventData &data) const
bool isUsed(const Trk::SpacePoint *, const Trk::PRDtoTrackMap &prd_to_track_map) const
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_prdToTrackMap
virtual MsgStream & dump(EventData &data, MsgStream &out) const override
void newOneSeed(EventData &data, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const float &, const float &) const
static void newSeed(EventData &data, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const float &)
bool isZCompatible(EventData &data, float &, float &, float &) const
virtual void writeNtuple(const SiSpacePointsSeed *seed, const Trk::Track *track, int seedType, long eventNumber) const override
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
bool solenoidOn() const
status of the magnets
void getFieldZR(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
get B field valaue on the z-r plane at given position works only inside the solenoid.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
Abstract Base Class for tracking surfaces.
This class is a simplest representation of a vertex candidate.
int ir
counter of the current depth
Definition fastadd.cxx:49
int r
Definition globals.cxx:22
int cost(std::vector< std::string > &files, node &n, const std::string &directory="", bool deleteref=false, bool relocate=false)
Definition hcg.cxx:922
Eigen::Matrix< double, 3, 1 > Vector3D
-event-from-file
hold the test vectors and ease the comparison
MsgStream & msg
Definition testRead.cxx:32