ATLAS Offline Software
Loading...
Searching...
No Matches
SiSpacePointsSeedMaker_Cosmic.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_Cosmic
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 <ostream>
21
23// Constructor
25
27(const std::string& t, const std::string& n, const IInterface* p)
28 : base_class(t, n, p)
29{
30}
31
33// Initialisation
35
37{
38 StatusCode sc = AlgTool::initialize();
39
41 ATH_CHECK(m_spacepointsSCT.initialize(m_sct));
43
44 ATH_CHECK( m_fieldCondObjInputKey.initialize() );
45
46 // PRD-to-track association (optional)
47 ATH_CHECK( m_prdToTrackMap.initialize( !m_prdToTrackMap.key().empty()));
48
49 // Build framework
50 //
52 if ( m_ptmin/m_fieldScale < 300.) m_ptmin = 300.*m_fieldScale;
53
54 // Get output print level
55 //
56 m_outputlevel = msg().level()-MSG::DEBUG;
57 if (m_outputlevel<=0) {
60 data.nprint=0;
61 dump(data, msg(MSG::DEBUG));
62 }
63
64 m_initialized = true;
65
66 return sc;
67}
68
70// Finalize
72
74{
75 return AlgTool::finalize();
76}
77
79// Initialize tool for new event
81
82void InDet::SiSpacePointsSeedMaker_Cosmic::newEvent(const EventContext& ctx, EventData& data, int) const
83{
84 if (!m_pixel && !m_sct) return;
85
86 if (not data.initialized) initializeEventData(data);
87
88 erase(data);
89 data.i_spforseed = data.l_spforseed.begin();
90
91 float irstep = 1./m_r_rstep;
92 std::array<float, 4> errorsc = {16.,16.,100.,16.};
93
95 const Trk::PRDtoTrackMap *prd_to_track_map_cptr = nullptr;
96 if (!m_prdToTrackMap.key().empty()) {
98 if (!prd_to_track_map.isValid()) {
99 ATH_MSG_ERROR("Failed to read PRD to track association map: " << m_prdToTrackMap.key());
100 }
101 prd_to_track_map_cptr=prd_to_track_map.cptr();
102 }
103
104 // Get pixels space points containers from store gate
105 //
106 if (m_pixel) {
107
109 if (spacepointsPixel.isValid()) {
110
111 for (const SpacePointCollection* spc: *spacepointsPixel) {
112 for (const Trk::SpacePoint* sp: *spc) {
113
114 float r = sp->r();
115 if (r<0. || r>=m_r_rmax) continue;
116 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
117
118 int ir = static_cast<int>((sp->globalPosition().y()+m_r_rmax)*irstep);
120 data.r_Sorted[ir].push_back(sps);
121 ++data.r_map[ir];
122 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
123 ++data.ns;
124 }
125 }
126 }
127 }
128
129 // Get sct space points containers from store gate
130 //
131 if (m_sct) {
132
134 if (spacepointsSCT.isValid()) {
135
136 for (const SpacePointCollection* spc: *spacepointsSCT) {
137 for (const Trk::SpacePoint* sp: *spc) {
138
139 float r = sp->r();
140 if (r<0. || r>=m_r_rmax) continue;
141 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
142
143 int ir = static_cast<int>((sp->globalPosition().y()+m_r_rmax)*irstep);
145 data.r_Sorted[ir].push_back(sps);
146 ++data.r_map[ir];
147 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
148 ++data.ns;
149 }
150 }
151 }
152
153 // Get sct overlap space points containers from store gate
154 //
155 if (m_useOverlap) {
156
158 if (spacepointsOverlap.isValid()) {
159
160 for (const Trk::SpacePoint* sp: *spacepointsOverlap) {
161
162 float r = sp->r();
163 if (r<0. || r>=m_r_rmax) continue;
164 if (prd_to_track_map_cptr && isUsed(sp, *prd_to_track_map_cptr)) continue;
165
166 int ir = static_cast<int>((sp->globalPosition().y()+m_r_rmax)*irstep);
168 data.r_Sorted[ir].push_back(sps);
169 ++data.r_map[ir];
170 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
171 ++data.ns;
172 }
173 }
174 }
175 }
177}
178
180// Initialize tool for new region
182
184(const EventContext& ctx, EventData& data,
185 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT) const
186{
187 if (not data.initialized) initializeEventData(data);
188
189 if (!m_pixel && !m_sct) return;
190 erase(data);
191 data.i_spforseed = data.l_spforseed.begin();
192
193 float irstep = 1.f/m_r_rstep;
194 std::array<float, 4> errorsc = {16.,16.,100.,16.};
195
196 SG::ReadHandle<Trk::PRDtoTrackMap> prd_to_track_map;
197 const Trk::PRDtoTrackMap *prd_to_track_map_cptr = nullptr;
198 if (!m_prdToTrackMap.key().empty()) {
200 if (!prd_to_track_map.isValid()) {
201 ATH_MSG_ERROR("Failed to read PRD to track association map: " << m_prdToTrackMap.key());
202 }
203 prd_to_track_map_cptr = prd_to_track_map.cptr();
204 }
205
206 // Get pixels space points containers from store gate
207 //
208 if (m_pixel && !vPixel.empty()) {
209
211 if (spacepointsPixel.isValid()) {
212 // Loop through all trigger collections
213 //
214 for (const IdentifierHash& l: vPixel) {
215 const auto *w = spacepointsPixel->indexFindPtr(l);
216 if (w==nullptr) continue;
217 for (const Trk::SpacePoint* sp: *w) {
218 float r = sp->r();
219 if (r<0. || r>=m_r_rmax) continue;
220 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
221
222 int ir = static_cast<int>((sp->globalPosition().y()+m_r_rmax)*irstep);
224 data.r_Sorted[ir].push_back(sps);
225 ++data.r_map[ir];
226 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
227 ++data.ns;
228 }
229 }
230 }
231 }
232
233 // Get sct space points containers from store gate
234 //
235 if (m_sct && !vSCT.empty()) {
236
238 if (spacepointsSCT.isValid()) {
239
240 // Loop through all trigger collections
241 //
242 for (const IdentifierHash& l: vSCT) {
243 const auto *w = spacepointsSCT->indexFindPtr(l);
244 if (w==nullptr) continue;
245 for (const Trk::SpacePoint* sp: *w) {
246 float r = sp->r();
247 if (r<0. || r>=m_r_rmax) continue;
248 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
249
250 int ir = static_cast<int>((sp->globalPosition().y()+m_r_rmax)*irstep);
252 data.r_Sorted[ir].push_back(sps);
253 ++data.r_map[ir];
254 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
255 ++data.ns;
256 }
257 }
258 }
259 }
261}
262
264// Initialize tool for new region
266
268(const EventContext& ctx, EventData& data,
269 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT, const IRoiDescriptor&) const
270{
271 newRegion(ctx, data, vPixel, vSCT);
272}
273
275// Methods to initilize different strategies of seeds production
276// with two space points with or without vertex constraint
278
279void InDet::SiSpacePointsSeedMaker_Cosmic::find2Sp(EventData& data, const std::list<Trk::Vertex>& lv) const
280{
281 if (not data.initialized) initializeEventData(data);
282
283 int mode = 0;
284 if (lv.begin()!=lv.end()) mode = 1;
285
286 data.nseeds = 0;
287 data.l_seeds_map.erase(data.l_seeds_map.begin(),data.l_seeds_map.end());
288
289 if ( !data.state || data.nspoint!=2 || data.mode!=mode || data.nlist) {
290
291 data.state = 1 ;
292 data.nspoint = 2 ;
293 data.nlist = 0 ;
294 data.mode = mode;
295 data.endlist = true;
296 data.fNmin = 0 ;
297 data.zMin = 0 ;
299 }
300
301 data.i_seed_map = data.l_seeds_map.begin();
302 data.i_seede_map = data.l_seeds_map.end ();
303
304 if (m_outputlevel<=0) {
305 data.nprint=1;
306 dump(data, msg(MSG::DEBUG));
307 }
308}
309
311// Methods to initilize different strategies of seeds production
312// with three space points with or without vertex constraint
314
315void InDet::SiSpacePointsSeedMaker_Cosmic::find3Sp(const EventContext& ctx, EventData& data, const std::list<Trk::Vertex>& lv) const
316{
317 if (not data.initialized) initializeEventData(data);
318
319 int mode = 2;
320 if (lv.begin()!=lv.end()) mode = 3;
321
322 data.nseeds = 0;
323 data.l_seeds_map.erase(data.l_seeds_map.begin(),data.l_seeds_map.end());
324
325 if (!data.state || data.nspoint!=3 || data.mode!=mode || data.nlist) {
326
327 data.state = 1 ;
328 data.nspoint = 3 ;
329 data.nlist = 0 ;
330 data.mode = mode ;
331 data.endlist = true ;
332 data.fNmin = 0 ;
333 data.zMin = 0 ;
334 production3Sp(ctx, data);
335 }
336
337 data.i_seed_map = data.l_seeds_map.begin();
338 data.i_seede_map = data.l_seeds_map.end ();
339
340 if (m_outputlevel<=0) {
341 data.nprint=1;
342 dump(data, msg(MSG::DEBUG));
343 }
344}
345
346void InDet::SiSpacePointsSeedMaker_Cosmic::find3Sp(const EventContext& ctx, EventData& data, const std::list<Trk::Vertex>& lv, const double*) const
347{
348 find3Sp(ctx, data, lv);
349}
350
352// Methods to initilize different strategies of seeds production
353// with variable number space points with or without vertex constraint
354// Variable means (2,3,4,....) any number space points
356
357void InDet::SiSpacePointsSeedMaker_Cosmic::findVSp(const EventContext& ctx, EventData& data, const std::list<Trk::Vertex>& lv) const
358{
359 if (not data.initialized) initializeEventData(data);
360
361 int mode = 5;
362 if (lv.begin()!=lv.end()) mode = 6;
363
364 if (!data.state || data.nspoint!=4 || data.mode!=mode || data.nlist) {
365
366 data.state = 1 ;
367 data.nspoint = 4 ;
368 data.nlist = 0 ;
369 data.mode = mode ;
370 data.endlist = true ;
371 data.fNmin = 0 ;
372 data.zMin = 0 ;
373 production3Sp(ctx, data);
374 }
375
376 data.i_seed_map = data.l_seeds_map.begin();
377 data.i_seede_map = data.l_seeds_map.end ();
378
379 if (m_outputlevel<=0) {
380 data.nprint=1;
381 dump(data, msg(MSG::DEBUG));
382 }
383}
384
386// Dumps relevant information into the MsgStream
388
390{
391 if (not data.initialized) initializeEventData(data);
392
393 if (data.nprint) return dumpEvent(data, out);
394 return dumpConditions(out);
395}
396
398// Dumps conditions information into the MsgStream
400
402{
403 int n = 42-m_spacepointsPixel.key().size();
404 std::string s2; for (int i=0; i<n; ++i) s2.append(" "); s2.append("|");
405 n = 42-m_spacepointsSCT.key().size();
406 std::string s3; for (int i=0; i<n; ++i) s3.append(" "); s3.append("|");
407 n = 42-m_spacepointsOverlap.key().size();
408 std::string s4; for (int i=0; i<n; ++i) s4.append(" "); s4.append("|");
409
410
411 out<<"|---------------------------------------------------------------------|"
412 <<endmsg;
413 out<<"| Pixel space points | "<<m_spacepointsPixel.key() <<s2
414 <<endmsg;
415 out<<"| SCT space points | "<<m_spacepointsSCT.key()<<s3
416 <<endmsg;
417 out<<"| Overlap space points | "<<m_spacepointsOverlap.key() <<s4
418 <<endmsg;
419 out<<"| usePixel | "
420 <<std::setw(12)<<m_pixel
421 <<" |"<<endmsg;
422 out<<"| useSCT | "
423 <<std::setw(12)<<m_sct
424 <<" |"<<endmsg;
425 out<<"| maxSize | "
426 <<std::setw(12)<<m_maxsize
427 <<" |"<<endmsg;
428 out<<"| maxSizeSP | "
429 <<std::setw(12)<<m_maxsizeSP
430 <<" |"<<endmsg;
431 out<<"| pTmin (mev) | "
432 <<std::setw(12)<<std::setprecision(5)<<m_ptmin
433 <<" |"<<endmsg;
434 out<<"| |eta| <= | "
435 <<std::setw(12)<<std::setprecision(5)<<m_etamax
436 <<" |"<<endmsg;
437 out<<"| max radius SP | "
438 <<std::setw(12)<<std::setprecision(5)<<m_r_rmax
439 <<" |"<<endmsg;
440 out<<"| radius step | "
441 <<std::setw(12)<<std::setprecision(5)<<m_r_rstep
442 <<" |"<<endmsg;
443 out<<"| min space points dR | "
444 <<std::setw(12)<<std::setprecision(5)<<m_drmin
445 <<" |"<<endmsg;
446 out<<"| max space points dR | "
447 <<std::setw(12)<<std::setprecision(5)<<m_drmax
448 <<" |"<<endmsg;
449 out<<"|---------------------------------------------------------------------|"
450 <<endmsg;
451 return out;
452}
453
455// Dumps event information into the MsgStream
457
459{
460 out<<"|---------------------------------------------------------------------|"
461 <<endmsg;
462 out<<"| data.ns | "
463 <<std::setw(12)<<data.ns
464 <<" |"<<endmsg;
465 out<<"| data.nsaz | "
466 <<std::setw(12)<<data.nsaz
467 <<" |"<<endmsg;
468 out<<"| seeds | "
469 <<std::setw(12)<<data.l_seeds_map.size()
470 <<" |"<<endmsg;
471 out<<"|---------------------------------------------------------------------|"
472 <<endmsg;
473 return out;
474}
475
477// Initiate frame work for seed generator
479
481{
482 m_etamax = std::abs(m_etamax);
483 m_dzdrmax = 1.f/std::tan(2.f*std::atan(std::exp(-m_etamax)));
485
486 // Build radius sorted containers
487 //
488 m_r_size = static_cast<int>((m_r_rmax+.1)/m_r_rstep)*2;
489
490 // Build radius-azimuthal sorted containers
491 //
492 constexpr float pi2 = 2.*M_PI;
493 const int NFmax = SizeRF;
494 const float sFmax = static_cast<float>(NFmax)/pi2;
495 const float sFmin = 50./60.;
496
497 m_sF = 50./60.;
498 if (m_sF >sFmax ) m_sF = sFmax ;
499 else if (m_sF < sFmin) m_sF = sFmin;
500 m_fNmax = static_cast<int>(pi2*m_sF);
501 if (m_fNmax >=NFmax) m_fNmax = NFmax-1;
502
503 // Build maps for radius-azimuthal-Z sorted collections
504 //
505 for (int f=0; f<=m_fNmax; ++f) {
506 int fb = f-1; if (fb<0 ) fb=m_fNmax;
507 int ft = f+1; if (ft>m_fNmax) ft=0;
508
509 // For each azimuthal region loop through all Z regions
510 //
511 for (int z=0; z<SizeZ; ++z) {
512 int a = f *SizeZ+z;
513 int b = fb*SizeZ+z;
514 int c = ft*SizeZ+z;
515 m_rfz_b [a] = 3; m_rfz_t [a] = 3;
516 m_rfz_ib[a][0] = a; m_rfz_it[a][0] = a;
517 m_rfz_ib[a][1] = b; m_rfz_it[a][1] = b;
518 m_rfz_ib[a][2] = c; m_rfz_it[a][2] = c;
519 if (z==5) {
520
521 m_rfz_t [a] = 9 ; m_rfz_b [a] = 9 ;
522 m_rfz_it[a][3] = a+1; m_rfz_ib[a][3] = a+1;
523 m_rfz_it[a][4] = b+1; m_rfz_ib[a][4] = b+1;
524 m_rfz_it[a][5] = c+1; m_rfz_ib[a][5] = c+1;
525 m_rfz_it[a][6] = a-1; m_rfz_ib[a][6] = a-1;
526 m_rfz_it[a][7] = b-1; m_rfz_ib[a][7] = b-1;
527 m_rfz_it[a][8] = c-1; m_rfz_ib[a][8] = c-1;
528 } else if (z> 5) {
529
530 m_rfz_b [a] = 6 ; m_rfz_t [a] = 6 ;
531 m_rfz_ib[a][3] = a-1; m_rfz_it[a][3] = a-1;
532 m_rfz_ib[a][4] = b-1; m_rfz_it[a][4] = b-1;
533 m_rfz_ib[a][5] = c-1; m_rfz_it[a][5] = c-1;
534
535 if (z<10) {
536
537 m_rfz_t [a] = 9 ; m_rfz_b [a] = 9 ;
538 m_rfz_it[a][6] = a+1; m_rfz_ib[a][6] = a+1;
539 m_rfz_it[a][7] = b+1; m_rfz_ib[a][7] = b+1;
540 m_rfz_it[a][8] = c+1; m_rfz_ib[a][8] = c+1;
541 }
542 } else {
543
544 m_rfz_b [a] = 6 ; m_rfz_t [a] = 6 ;
545 m_rfz_ib[a][3] = a+1; m_rfz_it[a][3] = a+1;
546 m_rfz_ib[a][4] = b+1; m_rfz_it[a][4] = b+1;
547 m_rfz_ib[a][5] = c+1; m_rfz_it[a][5] = c+1;
548
549 if (z>0) {
550
551 m_rfz_t [a] = 9 ; m_rfz_b [a] = 9 ;
552 m_rfz_it[a][6] = a-1; m_rfz_ib[a][6] = a-1;
553 m_rfz_it[a][7] = b-1; m_rfz_ib[a][7] = b-1;
554 m_rfz_it[a][8] = c-1; m_rfz_ib[a][8] = c-1;
555 }
556 }
557
558 if (z==3) {
559 m_rfz_b[a] = 12; m_rfz_t [a] = 12;
560 m_rfz_ib[a][ 9] = a+2; m_rfz_it[a][ 9] = a+2;
561 m_rfz_ib[a][10] = b+2; m_rfz_it[a][10] = b+2;
562 m_rfz_ib[a][11] = c+2; m_rfz_it[a][11] = c+2;
563 } else if (z==7) {
564 m_rfz_b[a] = 12; m_rfz_t [a] = 12;
565 m_rfz_ib[a][ 9] = a-2; m_rfz_it[a][ 9] = a-2;
566 m_rfz_ib[a][10] = b-2; m_rfz_it[a][10] = b-2;
567 m_rfz_ib[a][11] = c-2; m_rfz_it[a][11] = c-2;
568 }
569 }
570 }
571}
572
574// Initiate space points seed maker
576
578{
579 constexpr float pi2 = 2.*M_PI;
580
581 for (int i=0; i<m_r_size; ++i) {
582 if (!data.r_map[i]) continue;
583
584 for (InDet::SiSpacePointForSeed* r : data.r_Sorted[i]) {
585
586 // Azimuthal angle sort
587 //
588 float F = r->phi();
589 if (F<0.) F+=pi2;
590
591 //int f = static_cast<int>(F*m_sF); f<0 ? f = m_fNmax : f>m_fNmax ? f = 0 : f=f;
592 int f = 1;
593 data.rf_Sorted[f].push_back(r);
594 if (!data.rf_map[f]++) data.rf_index[data.nrf++] = f;
595
596 float Z = r->z();
597 // Azimuthal angle and Z-coordinate sort
598 //
599 int z;
600 if (Z>0.) {
601 Z< 250.?z=5:Z< 450.?z=6:Z< 925.?z=7:Z< 1400.?z=8:Z< 2500.?z=9:z=10;
602 } else {
603 Z>-250.?z=5:Z>-450.?z=4:Z>-925.?z=3:Z>-1400.?z=2:Z>-2500.?z=1:z= 0;
604 }
605 int n = f*SizeZ+z;
606 ++data.nsaz;
607 data.rfz_Sorted[n].push_back(r);
608 if (!data.rfz_map[n]++) data.rfz_index[data.nrfz++] = n;
609 }
610 data.r_Sorted[i].clear();
611 data.r_map[i] = 0;
612 }
613 data.nr = 0;
614 data.state = 0;
615}
616
618// Erase space point information
620
622{
623 for (int i=0; i<data.nr; ++i) {
624 int n = data.r_index[i];
625 data.r_map[n] = 0;
626 data.r_Sorted[n].erase(data.r_Sorted[n].begin(), data.r_Sorted[n].end());
627 }
628
629 for (int i=0; i>data.nrf; ++i) {
630 int n = data.rf_index[i];
631 data.rf_map[n] = 0;
632 data.rf_Sorted[n].erase(data.rf_Sorted[n].begin(), data.rf_Sorted[n].end());
633 }
634
635 for (int i=0; i<data.nrfz; ++i) {
636 int n = data.rfz_index[i];
637 data.rfz_map[n] = 0;
638 data.rfz_Sorted[n].erase(data.rfz_Sorted[n].begin(), data.rfz_Sorted[n].end());
639 }
640
641 data.state = 0;
642 data.ns = 0;
643 data.nsaz = 0;
644 data.nr = 0;
645 data.nrf = 0;
646 data.nrfz = 0;
647}
648
650// 2 space points seeds production
652
657
659// Production 3 space points seeds
661
663{
664 if (data.nsaz<3) return;
665
666 float K = 0.;
667
668 double f[3], gP[3] ={10.,10.,0.};
669
670 MagField::AtlasFieldCache fieldCache;
671 // Get field cache object
673 const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
674 if (fieldCondObj == nullptr) {
675 ATH_MSG_ERROR("SiSpacePointsSeedMaker_Cosmic: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCondObjInputKey.key());
676 return;
677 }
678 fieldCondObj->getInitializedCache (fieldCache);
679
680 if (fieldCache.solenoidOn()) {
681 fieldCache.getFieldZR(gP,f);
682
683 K = 2./(300.*f[2]);
684 }
685 if (!K) return production3SpWithoutField(data);
686
687 float ipt = 100000000.;
688 if (m_ptmin!=0.) ipt= 1.f/std::abs(.9f*m_ptmin);
689
690 const int ZI[SizeZ]= {5,6,7,8,9,10,4,3,2,1,0};
691 std::vector<InDet::SiSpacePointForSeed*>::iterator rt[9],rte[9],rb[9],rbe[9];
692
693 // Loop thorugh all azimuthal regions
694 //
695 for (int f=data.fNmin; f<=m_fNmax; ++f) {
696 // For each azimuthal region loop through all Z regions
697 //
698 int z = 0;
699 if (!data.endlist) z = data.zMin;
700
701 for (; z<SizeZ; ++z) {
702 int a = f *SizeZ+ZI[z];
703 if (!data.rfz_map[a]) continue;
704 int NB = 0, NT = 0;
705 for (int i=0; i<m_rfz_b[a]; ++i) {
706
707 int an = m_rfz_ib[a][i];
708 if (!data.rfz_map[an]) continue;
709 rb [NB] = data.rfz_Sorted[an].begin();
710 rbe[NB++] = data.rfz_Sorted[an].end();
711 }
712 for (int i=0; i<m_rfz_t[a]; ++i) {
713 int an = m_rfz_it[a][i];
714 if (!data.rfz_map[an]) continue;
715 rt [NT] = data.rfz_Sorted[an].begin();
716 rte[NT++] = data.rfz_Sorted[an].end();
717 }
718 production3Sp(data, rb, rbe, rt, rte, NB, NT, K, ipt);
719 if (!data.endlist) {data.fNmin=f; data.zMin = z; return;}
720 }
721 }
722 data.endlist = true;
723}
724
726// Production 3 space points seeds without magnetic field
728
730{
731
732 float ipt = 100000000.;
733 if (m_ptmin!=0.) ipt= 1.f/std::abs(.9f*m_ptmin);
734 const int ZI[SizeZ]= {5,6,7,8,9,10,4,3,2,1,0};
735 std::vector<InDet::SiSpacePointForSeed*>::iterator rt[9],rte[9],rb[9],rbe[9];
736
737 // Loop thorugh all azimuthal regions
738 //
739 for (int f=data.fNmin; f<=m_fNmax; ++f) {
740 // For each azimuthal region loop through all Z regions
741 //
742 int z = 0;
743 if (!data.endlist) z = data.zMin;
744
745 for (; z<SizeZ; ++z) {
746 int a = f *SizeZ+ZI[z];
747 if (!data.rfz_map[a]) continue;
748 int NB = 0, NT = 0;
749 for (int i=0; i<m_rfz_b[a]; ++i) {
750 int an = m_rfz_ib[a][i];
751 if (!data.rfz_map[an]) continue;
752 rb [NB] = data.rfz_Sorted[an].begin();
753 rbe[NB++] = data.rfz_Sorted[an].end();
754 }
755 for (int i=0; i<m_rfz_t[a]; ++i) {
756 int an = m_rfz_it[a][i];
757 if (!data.rfz_map[an]) continue;
758 rt [NT] = data.rfz_Sorted[an].begin();
759 rte[NT++] = data.rfz_Sorted[an].end();
760 }
761 production3SpWithoutField(data, rb, rbe, rt, rte, NB, NT, ipt);
762 if (!data.endlist) {data.fNmin=f; data.zMin = z; return;}
763 }
764 }
765 data.endlist = true;
766}
767
769// Production 3 space points seeds (new version)
771
774 std::vector<InDet::SiSpacePointForSeed*>::iterator* rb ,
775 std::vector<InDet::SiSpacePointForSeed*>::iterator* rbe,
776 std::vector<InDet::SiSpacePointForSeed*>::iterator* rt ,
777 std::vector<InDet::SiSpacePointForSeed*>::iterator* rte,
778 int NB, int NT, float K, float ipt) const
779{
780 const float COF = 134*.05*9.;
781
782 std::vector<InDet::SiSpacePointForSeed*>::iterator r0=rb[0],r;
783 if (!data.endlist) {r0 = data.rMin; data.endlist = true;}
784
785 // Loop through all trigger space points
786 //
787 for (; r0!=rbe[0]; ++r0) {
788 bool pix = true;
789 if ((*r0)->spacepoint->clusterList().second) pix = false;
790 float R = (*r0)->radius();
791 const Trk::Surface* sur0 = (*r0)->sur();
792 float X = (*r0)->x() ;
793 float Y = (*r0)->y() ;
794 float Z = (*r0)->z() ;
795 float ax = X/R ;
796 float ay = Y/R ;
797 float covr0 = (*r0)->covr ();
798 float covz0 = (*r0)->covz ();
799 int Nb = 0;
800
801 // Bottom links production
802 //
803 for (int i=0; i<NB; ++i) {
804 for (r=rb[i]; r!=rbe[i]; ++r) {
805 float dy = (*r)->y()-Y ;
806 if (-dy < m_drmin) break;
807 if (-dy > m_drmax || (*r)->sur()==sur0) continue;
808
809 if (!pix && !(*r)->spacepoint->clusterList().second) continue;
810 if ( pix && (*r)->spacepoint->clusterList().second) continue;
811
812 float dx = (*r)->x()-X;
813 float dz = (*r)->z()-Z;
814
815 float x = dx*ax+dy*ay ;
816 float y =-dx*ay+dy*ax ;
817 float r2 = 1.f/(x*x+y*y);
818 float dr = std::sqrt(r2);
819 data.Tz[Nb] = -dz*dr;
820
821 if (data.Tz[Nb]<m_dzdrmin || data.Tz[Nb]>m_dzdrmax) continue;
822
823 data.SP[Nb] = (*r);
824 data.U [Nb] = x*r2;
825 data.V [Nb] = y*r2;
826 data.Er[Nb] = (covz0+data.SP[Nb]->covz()+data.Tz[Nb]*data.Tz[Nb]*(covr0+data.SP[Nb]->covr()))*r2;
827 data.R [Nb] = dr ;
828 if (++Nb==m_maxsizeSP) goto breakb;
829 }
830 }
831 breakb:
832
833 if (!Nb || Nb==m_maxsizeSP) continue;
834 int Nt = Nb;
835
836 // Top links production
837 //
838 for (int i=0; i<NT; ++i) {
839 for (r=rt[i]; r!=rte[i]; ++r) {
840 float dy = (*r)->y()-Y ;
841 if (dy < m_drmin) {rt[i]=r; continue;}
842 if (dy>m_drmax) break;
843 if ((*r)->sur()==sur0) continue;
844
845 if ( pix && (*r)->spacepoint->clusterList().second) continue;
846 if (!pix && !(*r)->spacepoint->clusterList().second) continue;
847
848 float dx = (*r)->x()-X;
849 float dz = (*r)->z()-Z;
850
851 float x = dx*ax+dy*ay;
852 float y =-dx*ay+dy*ax;
853 float r2 = 1.f/(x*x+y*y);
854 float dr = std::sqrt(r2);
855 data.Tz[Nt] = dz*dr;
856 if (data.Tz[Nt]<m_dzdrmin || data.Tz[Nt]>m_dzdrmax) continue;
857
858 data.SP[Nt] = (*r);
859 data.U [Nt] = x*r2;
860 data.V [Nt] = y*r2;
861 data.Er[Nt] = (covz0+data.SP[Nt]->covz()+data.Tz[Nt]*data.Tz[Nt]*(covr0+data.SP[Nt]->covr()))*r2;
862 data.R [Nt] = dr;
863 if (++Nt==m_maxsizeSP) goto breakt;
864 }
865 }
866
867 breakt:
868
869 if (!(Nt-Nb)) continue;
870
871 // Three space points comparison
872 //
873 for (int b=Nb-1; b>=0; --b) {
874 float SA = 1.+data.Tz[b]*data.Tz[b];
875 for (int t=Nb; t<Nt; ++t) {
876 float Ts = .5f*(data.Tz[b]+data.Tz[t]);
877 float dt = data.Tz[b]-data.Tz[t] ;
878 float dT = dt*dt-data.Er[b]-data.Er[t]-2.*data.R[b]*data.R[t]*(Ts*Ts*covr0+covz0);
879 if ( dT > 0. && dT > (ipt*ipt)*COF*SA ) continue;
880 float dU = data.U[t]-data.U[b]; if (dU == 0.) continue;
881 float A = (data.V[t]-data.V[b])/dU ;
882 float B = data.V[t]-A*data.U[t] ;
883 float S2 = 1.f+A*A ;
884 float S = std::sqrt(S2) ;
885 float BK = std::abs(B*K) ;
886 if (BK > ipt*S) continue ; // Momentum cut
887 dT -= ((BK*BK)*COF*SA/S2) ;
888 if (dT > 0.) continue ; // Polar angle cut
889 dT*= ((data.R[b]*data.R[t])/(data.R[b]+data.R[t]));
890
891 newSeed(data, data.SP[b]->spacepoint,(*r0)->spacepoint,data.SP[t]->spacepoint,dT);
892 }
893 }
894 }
895}
896
898// Production 3 space points seeds without magnetic field
900
903 std::vector<InDet::SiSpacePointForSeed*>::iterator* rb ,
904 std::vector<InDet::SiSpacePointForSeed*>::iterator* rbe,
905 std::vector<InDet::SiSpacePointForSeed*>::iterator* rt ,
906 std::vector<InDet::SiSpacePointForSeed*>::iterator* rte,
907 int NB, int NT,float ipt) const
908{
909 const float COF = 134*.05*9.;
910 const float dFcut = .96 ;
911
912 std::vector<InDet::SiSpacePointForSeed*>::iterator r0=rb[0],r;
913 if (!data.endlist) {r0 = data.rMin; data.endlist = true;}
914
915 // Loop through all trigger space points
916 //
917 for (; r0!=rbe[0]; ++r0) {
918 bool pix = true;
919 if ((*r0)->spacepoint->clusterList().second) pix = false;
920 const Trk::Surface* sur0 = (*r0)->sur() ;
921 float X = (*r0)->x() ;
922 float Y = (*r0)->y() ;
923 float Z = (*r0)->z() ;
924 float covr0 = (*r0)->covr ();
925 float covz0 = (*r0)->covz ();
926
927 int Nb = 0;
928
929 // Bottom links production
930 //
931 for (int i=0; i<NB; ++i) {
932 for (r=rb[i]; r!=rbe[i]; ++r) {
933 float dy = Y-(*r)->y() ;
934 if ( dy < m_drmin) break;
935 if ( dy > m_drmax || (*r)->sur()==sur0) continue;
936
937 if (!pix && !(*r)->spacepoint->clusterList().second) continue;
938 if ( pix && (*r)->spacepoint->clusterList().second) continue;
939
940 float dx = X-(*r)->x();
941 float dz = Z-(*r)->z();
942 float r2 = 1.f/(dx*dx+dy*dy);
943 float dr = std::sqrt(r2);
944 data.Tz[Nb] = dz*dr;
945 if (data.Tz[Nb]<m_dzdrmin || data.Tz[Nb]>m_dzdrmax) continue;
946
947 data.SP[Nb] = (*r) ;
948 data.U [Nb] = dx*dr;
949 data.V [Nb] = dy*dr;
950 data.Er[Nb] = (covz0+data.SP[Nb]->covz()+data.Tz[Nb]*data.Tz[Nb]*(covr0+data.SP[Nb]->covr()))*r2;
951 data.R [Nb] = dr ;
952 if (++Nb==m_maxsizeSP) goto breakb;
953 }
954 }
955 breakb:
956
957 if (!Nb || Nb==m_maxsizeSP) continue;
958 int Nt = Nb;
959
960 // Top links production
961 //
962 for (int i=0; i<NT; ++i) {
963 for (r=rt[i]; r!=rte[i]; ++r) {
964 float dy = (*r)->y()-Y ;
965 if (dy < m_drmin) {rt[i]=r; continue;}
966 if (dy>m_drmax) break;
967 if ((*r)->sur()==sur0) continue;
968
969 if ( pix && (*r)->spacepoint->clusterList().second) continue;
970 if (!pix && !(*r)->spacepoint->clusterList().second) continue;
971
972 float dx = (*r)->x()-X;
973 float dz = (*r)->z()-Z;
974 float r2 = 1.f/(dx*dx+dy*dy);
975 float dr = std::sqrt(r2);
976 data.Tz[Nt] = dz*dr;
977 if (data.Tz[Nt]<m_dzdrmin || data.Tz[Nt]>m_dzdrmax) continue;
978
979 data.SP[Nt] = (*r) ;
980 data.U [Nt] = dx*dr;
981 data.V [Nt] = dy*dr;
982 data.Er[Nt] = (covz0+data.SP[Nt]->covz()+data.Tz[Nt]*data.Tz[Nt]*(covr0+data.SP[Nt]->covr()))*r2;
983 data.R [Nt] = dr ;
984 if (++Nt==m_maxsizeSP) goto breakt;
985 }
986 }
987
988 breakt:
989
990 if (!(Nt-Nb)) continue;
991
992 // Three space points comparison
993 //
994 for (int b=Nb-1; b>=0; --b) {
995 float SA = 1.f+data.Tz[b]*data.Tz[b];
996 for (int t=Nb; t<Nt; ++t) {
997 // Azimuth angle cut
998 //
999 float dF = data.U[b]*data.U[t]+data.V[b]*data.V[t];
1000 if (dF < dFcut) continue;
1001
1002 // Polar angle cut
1003 //
1004 float Ts = .5f*(data.Tz[b]+data.Tz[t]);
1005 float dT = data.Tz[b]-data.Tz[t] ;
1006 dT = dT*dT-data.Er[b]-data.Er[t]-2.f*data.R[b]*data.R[t]*(Ts*Ts*covr0+covz0);
1007 dT -= (ipt*ipt)*COF*SA ;
1008 if ( dT > 0. ) continue ;
1009
1010 dT*= ((data.R[b]*data.R[t])/(data.R[b]+data.R[t]));
1011
1012 newSeed(data, data.SP[b]->spacepoint,(*r0)->spacepoint,data.SP[t]->spacepoint,dT);
1013 }
1014 }
1015 }
1016}
1017
1019// Test is space point used
1021
1023{
1024 if (not data.initialized) initializeEventData(data);
1025
1026 if (data.i_seed_map==data.i_seede_map) return nullptr;
1027 InDet::SiSpacePointsSeed* sp = (*data.i_seed_map).second;
1028 ++data.i_seed_map;
1029 return sp;
1030}
1031
1033// New space point for seeds
1035
1037(EventData& data, const Trk::SpacePoint*const& sp)
1038{
1039 InDet::SiSpacePointForSeed* sps = nullptr;
1040
1041 std::array<float, 3> r = {static_cast<float>(sp->globalPosition().x()),
1042 static_cast<float>(sp->globalPosition().y()),
1043 static_cast<float>(sp->globalPosition().z())};
1044
1045 if (data.i_spforseed!=data.l_spforseed.end()) {
1046 sps = &(*data.i_spforseed++);
1047 sps->set(sp, r);
1048 } else {
1049 data.l_spforseed.emplace_back(sp, r);
1050 sps = &(data.l_spforseed.back());
1051 data.i_spforseed = data.l_spforseed.end();
1052 }
1053
1054 return sps;
1055}
1056
1058// New space point for seeds with error correction
1060
1062(EventData& data, const Trk::SpacePoint*const& sp, std::span<float const, 4> sc)
1063{
1064 InDet::SiSpacePointForSeed* sps = nullptr;
1065
1066 std::array<float,3> r;
1067 r[0]=sp->globalPosition().x();
1068 r[1]=sp->globalPosition().y();
1069 r[2]=sp->globalPosition().z();
1070
1071 if (data.i_spforseed!=data.l_spforseed.end()) {
1072 sps = &(*data.i_spforseed++);
1073 sps->set(sp, r, sc);
1074 } else {
1075 data.l_spforseed.emplace_back(sp, r, sc);
1076 sps = &(data.l_spforseed.back());
1077 data.i_spforseed = data.l_spforseed.end();
1078 }
1079
1080 return sps;
1081}
1082
1084// New 2 space points seeds
1086
1088(EventData& data,
1089 const Trk::SpacePoint*& p1,const Trk::SpacePoint*& p2,
1090 const float& z) const
1091{
1092 if (data.nseeds < m_maxsize) {
1093 data.seeds[data.nseeds].erase ( );
1094 data.seeds[data.nseeds].add (p1);
1095 data.seeds[data.nseeds].add (p2);
1096 data.seeds[data.nseeds].setZVertex(0.);
1097 data.l_seeds_map.insert(std::make_pair(z, &(data.seeds[data.nseeds])));
1098 ++data.nseeds;
1099 } else {
1100 std::multimap<float,InDet::SiSpacePointsSeed*>::reverse_iterator l = data.l_seeds_map.rbegin();
1101 if ((*l).first <= z) return;
1102 InDet::SiSpacePointsSeed* s = (*l).second;
1103 data.l_seeds_map.erase((*l).first);
1104
1105 s->erase ( );
1106 s->add (p1);
1107 s->add (p2);
1108 s->setZVertex(0.);
1109 data.l_seeds_map.insert(std::make_pair(z,s));
1110 }
1111}
1112
1114// New 3 space points seeds
1116
1118(EventData& data,
1119 const Trk::SpacePoint*& p1,const Trk::SpacePoint*& p2,
1120 const Trk::SpacePoint*& p3,const float& z) const
1121{
1122 if (data.nseeds < m_maxsize) {
1123 data.seeds[data.nseeds].erase ( );
1124 data.seeds[data.nseeds].add (p1);
1125 data.seeds[data.nseeds].add (p2);
1126 data.seeds[data.nseeds].add (p3);
1127 data.seeds[data.nseeds].setZVertex(0.);
1128 data.l_seeds_map.insert(std::make_pair(z, &(data.seeds[data.nseeds])));
1129 ++data.nseeds;
1130 } else {
1131 std::multimap<float,InDet::SiSpacePointsSeed*>::reverse_iterator l = data.l_seeds_map.rbegin();
1132 if ((*l).first <= z) return;
1133 InDet::SiSpacePointsSeed* s = (*l).second;
1134 data.l_seeds_map.erase((*l).first);
1135
1136 s->erase ( );
1137 s->add (p1);
1138 s->add (p2);
1139 s->add (p3);
1140 s->setZVertex(0.);
1141 data.l_seeds_map.insert(std::make_pair(z,s));
1142 }
1143}
1144
1146 data.initialize(EventData::ToolType::Cosmic,
1148 0, // maxOneSize not used
1149 m_maxsize,
1150 m_r_size,
1151 SizeRF,
1152 SizeRFZ,
1153 0, // sizeRFZV not used
1154 false); // checkEta not used
1155}
1156
1159
#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
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 >)
void production3Sp(const EventContext &ctx, EventData &data) const
virtual void newEvent(const EventContext &ctx, EventData &data, int iteration) const override
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_prdToTrackMap
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,...
virtual MsgStream & dump(EventData &data, MsgStream &out) const override
SG::ReadHandleKey< SpacePointContainer > m_spacepointsPixel
void newSeed(EventData &data, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const float &) const
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCondObjInputKey
static SiSpacePointForSeed * newSpacePoint(EventData &data, const Trk::SpacePoint *const &)
virtual void writeNtuple(const SiSpacePointsSeed *seed, const Trk::Track *track, int seedType, long eventNumber) const override
virtual const SiSpacePointsSeed * next(const EventContext &ctx, EventData &data) const override
static MsgStream & dumpEvent(EventData &data, MsgStream &out)
virtual void find2Sp(EventData &data, const std::list< Trk::Vertex > &lv) const override
with two space points with or without vertex constraint
bool isUsed(const Trk::SpacePoint *, const Trk::PRDtoTrackMap &prd_to_track_map) const
SG::ReadHandleKey< SpacePointContainer > m_spacepointsSCT
virtual void newRegion(const EventContext &ctx, EventData &data, const std::vector< IdentifierHash > &vPixel, const std::vector< IdentifierHash > &vSCT) 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
SG::ReadHandleKey< SpacePointOverlapCollection > m_spacepointsOverlap
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.
int ir
counter of the current depth
Definition fastadd.cxx:49
int r
Definition globals.cxx:22
-event-from-file
hold the test vectors and ease the comparison
MsgStream & msg
Definition testRead.cxx:32