ATLAS Offline Software
Loading...
Searching...
No Matches
SiSpacePointsSeedMaker_BeamGas.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_BeamGas
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
18#include <cmath>
19
20#include <iomanip>
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_BeamGas::newEvent(const EventContext& ctx, EventData& data, int) const
87{
88 if (!m_pixel && !m_sct) return;
89
90 if (not data.initialized) initializeEventData(data);
91
92 erase(data);
94
95 double f[3], gP[3] ={10.,10.,0.};
96
98 // Get field cache object
100 const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
101 if (fieldCondObj == nullptr) {
102 ATH_MSG_ERROR("SiSpacePointsSeedMaker_BeamGas: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCondObjInputKey.key());
103 return;
104 }
105 fieldCondObj->getInitializedCache (fieldCache);
106
107 if (fieldCache.solenoidOn()) {
108 fieldCache.getFieldZR(gP,f);
109
110 data.K = 2./(300.*f[2]);
111 } else {
112 data.K = 2./(300.* 5. );
113 }
114
115 data.i_spforseed = data.l_spforseed.begin();
116
117 float irstep = 1.f/m_r_rstep;
118
119
120 SG::ReadHandle<Trk::PRDtoTrackMap> prd_to_track_map;
121 const Trk::PRDtoTrackMap *prd_to_track_map_cptr = nullptr;
122 if (!m_prdToTrackMap.key().empty()) {
124 if (!prd_to_track_map.isValid()) {
125 ATH_MSG_ERROR("Failed to read PRD to track association map: " << m_prdToTrackMap.key());
126 }
127 prd_to_track_map_cptr = prd_to_track_map.cptr();
128 }
129
130 // Get pixels space points containers from store gate
131 //
132 if (m_pixel) {
133
135 if (spacepointsPixel.isValid()) {
136
137 for (const SpacePointCollection* spc: *spacepointsPixel) {
138 for (const Trk::SpacePoint* sp: *spc) {
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>(r*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
154 // Get sct space points containers from store gate
155 //
156 if (m_sct) {
157
159 if (spacepointsSCT.isValid()) {
160
161 for (const SpacePointCollection* spc: *spacepointsSCT) {
162 for (const Trk::SpacePoint* sp: *spc) {
163 float r = sp->r();
164 if (r<0. || r>=m_r_rmax) continue;
165 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
166
167 int ir = static_cast<int>(r*irstep);
169 data.r_Sorted[ir].push_back(sps);
170 ++data.r_map[ir];
171 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
172 ++data.ns;
173 }
174 }
175 }
176
177 // Get sct overlap space points containers from store gate
178 //
179 if (m_useOverlap) {
180
182 if (spacepointsOverlap.isValid()) {
183
184 for (const Trk::SpacePoint* sp: *spacepointsOverlap) {
185
186 float r = sp->r();
187 if (r<0. || r>=m_r_rmax) continue;
188 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
189
190 int ir = static_cast<int>(r*irstep);
192 data.r_Sorted[ir].push_back(sps);
193 ++data.r_map[ir];
194 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
195 ++data.ns;
196 }
197 }
198 }
199 }
201}
202
204// Initialize tool for new region
206
208(const EventContext& ctx, EventData& data,
209 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT) const
210{
211 if (!m_pixel && !m_sct) return;
212
213 if (not data.initialized) initializeEventData(data);
214
215 erase(data);
217
218 double f[3], gP[3] ={10.,10.,0.};
219
220 MagField::AtlasFieldCache fieldCache;
221 // Get field cache object
223 const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
224 if (fieldCondObj == nullptr) {
225 ATH_MSG_ERROR("SiSpacePointsSeedMaker_BeamGas: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCondObjInputKey.key());
226 return;
227 }
228 fieldCondObj->getInitializedCache (fieldCache);
229
230 if (fieldCache.solenoidOn()) {
231 fieldCache.getFieldZR(gP,f);
232
233 data.K = 2./(300.*f[2]);
234 } else {
235 data.K = 2./(300.* 5. );
236 }
237
238 data.i_spforseed = data.l_spforseed.begin();
239
240 float irstep = 1.f/m_r_rstep;
241
242 SG::ReadHandle<Trk::PRDtoTrackMap> prd_to_track_map;
243 const Trk::PRDtoTrackMap *prd_to_track_map_cptr = nullptr;
244 if (!m_prdToTrackMap.key().empty()) {
246 if (!prd_to_track_map.isValid()) {
247 ATH_MSG_ERROR("Failed to read PRD to track association map: " << m_prdToTrackMap.key());
248 }
249 prd_to_track_map_cptr = prd_to_track_map.cptr();
250 }
251
252 // Get pixels space points containers from store gate
253 //
254 if (m_pixel && !vPixel.empty()) {
255
257 if (spacepointsPixel.isValid()) {
258
259 // Loop through all trigger collections
260 //
261 for (const IdentifierHash& l: vPixel) {
262 const auto *w = spacepointsPixel->indexFindPtr(l);
263 if (w==nullptr) continue;
264 for (const Trk::SpacePoint* sp: *w) {
265 float r = sp->r();
266 if (r<0. || r>=m_r_rmax) continue;
267 if (prd_to_track_map_cptr && isUsed(sp, *prd_to_track_map_cptr)) continue;
268 int ir = static_cast<int>(r*irstep);
270 data.r_Sorted[ir].push_back(sps);
271 ++data.r_map[ir];
272 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
273 ++data.ns;
274 }
275 }
276 }
277 }
278
279 // Get sct space points containers from store gate
280 //
281 if (m_sct && !vSCT.empty()) {
282
284 if (spacepointsSCT.isValid()) {
285 // Loop through all trigger collections
286 //
287 for (const IdentifierHash& l: vPixel) {
288 const auto *w = spacepointsSCT->indexFindPtr(l);
289 if (w==nullptr) continue;
290 for (const Trk::SpacePoint* sp: *w) {
291 float r = sp->r();
292 if (r<0. || r>=m_r_rmax) continue;
293 if (prd_to_track_map_cptr && isUsed(sp,*prd_to_track_map_cptr)) continue;
294 int ir = static_cast<int>(r*irstep);
296 data.r_Sorted[ir].push_back(sps);
297 ++data.r_map[ir];
298 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
299 ++data.ns;
300 }
301 }
302 }
303 }
305}
306
307
309// Initialize tool for new region
311
313(const EventContext& ctx, EventData& data,
314 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT, const IRoiDescriptor&) const
315{
316 newRegion(ctx, data, vPixel, vSCT);
317}
318
320// Methods to initilize different strategies of seeds production
321// with two space points with or without vertex constraint
323
324void InDet::SiSpacePointsSeedMaker_BeamGas::find2Sp(EventData& data, const std::list<Trk::Vertex>& lv) const
325{
326 if (not data.initialized) initializeEventData(data);
327
328 int mode = 0;
329 if (lv.begin()!=lv.end()) mode = 1;
330
331 if (!data.state || data.nspoint!=2 || data.mode!=mode || data.nlist) {
332 data.i_seede = data.l_seeds.begin();
333 data.state = 1;
334 data.nspoint = 2;
335 data.nlist = 0;
336 data.mode = mode;
337 data.endlist = true;
338 data.fNmin = 0;
339 data.zMin = 0;
341 }
342 data.i_seed = data.l_seeds.begin();
343
344 if (m_outputlevel<=0) {
345 data.nprint=1;
346 dump(data, msg(MSG::DEBUG));
347 }
348}
349
351// Methods to initilize different strategies of seeds production
352// with three space points with or without vertex constraint
354
355void InDet::SiSpacePointsSeedMaker_BeamGas::find3Sp(const EventContext&, EventData& data, const std::list<Trk::Vertex>& lv) const
356{
357 if (not data.initialized) initializeEventData(data);
358
359 int mode = 2;
360 if (lv.begin()!=lv.end()) mode = 3;
361
362 if (!data.state || data.nspoint!=3 || data.mode!=mode || data.nlist) {
363 data.i_seede = data.l_seeds.begin();
364 data.state = 1;
365 data.nspoint = 3;
366 data.nlist = 0;
367 data.mode = mode;
368 data.endlist = true;
369 data.fNmin = 0;
370 data.zMin = 0;
372 }
373 data.i_seed = data.l_seeds.begin();
374
375 if (m_outputlevel<=0) {
376 data.nprint=1;
377 dump(data, msg(MSG::DEBUG));
378 }
379}
380void InDet::SiSpacePointsSeedMaker_BeamGas::find3Sp(const EventContext& ctx, EventData& data, const std::list<Trk::Vertex>& lv, const double*) const
381{
382 find3Sp(ctx, data, lv);
383}
384
386// Methods to initilize different strategies of seeds production
387// with variable number space points with or without vertex constraint
388// Variable means (2,3,4,....) any number space points
390
391void InDet::SiSpacePointsSeedMaker_BeamGas::findVSp(const EventContext&, EventData& data, const std::list<Trk::Vertex>& lv) const
392{
393 if (not data.initialized) initializeEventData(data);
394
395 int mode = 5;
396 if (lv.begin()!=lv.end()) mode = 6;
397
398 if (!data.state || data.nspoint!=4 || data.mode!=mode || data.nlist) {
399 data.i_seede = data.l_seeds.begin();
400 data.state = 1;
401 data.nspoint = 4;
402 data.nlist = 0;
403 data.mode = mode;
404 data.endlist = true;
405 data.fNmin = 0;
406 data.zMin = 0;
408 }
409 data.i_seed = data.l_seeds.begin();
410
411 if (m_outputlevel<=0) {
412 data.nprint=1;
413 dump(data, msg(MSG::DEBUG));
414 }
415}
416
418// Dumps relevant information into the MsgStream
420
422{
423 if (not data.initialized) initializeEventData(data);
424
425 if (data.nprint) return dumpEvent(data, out);
426 return dumpConditions(data, out);
427}
428
430// Dumps conditions information into the MsgStream
432
434{
435 int n = 42-m_spacepointsPixel.key().size();
436 std::string s2; for (int i=0; i<n; ++i) s2.append(" "); s2.append("|");
437 n = 42-m_spacepointsSCT.key().size();
438 std::string s3; for (int i=0; i<n; ++i) s3.append(" "); s3.append("|");
439 n = 42-m_spacepointsOverlap.key().size();
440 std::string s4; for (int i=0; i<n; ++i) s4.append(" "); s4.append("|");
441 n = 42-m_beamSpotKey.key().size();
442 std::string s5; for (int i=0; i<n; ++i) s5.append(" "); s5.append("|");
443
444
445 out<<"|---------------------------------------------------------------------|"
446 <<endmsg;
447 out<<"| Pixel space points | "<<m_spacepointsPixel.key() <<s2
448 <<endmsg;
449 out<<"| SCT space points | "<<m_spacepointsSCT.key() <<s3
450 <<endmsg;
451 out<<"| Overlap space points | "<<m_spacepointsOverlap.key() <<s4
452 <<endmsg;
453 out<<"| BeamConditionsService | "<<m_beamSpotKey.key()<<s5
454 <<endmsg;
455 out<<"| usePixel | "
456 <<std::setw(12)<<m_pixel
457 <<" |"<<endmsg;
458 out<<"| useSCT | "
459 <<std::setw(12)<<m_sct
460 <<" |"<<endmsg;
461 out<<"| maxSize | "
462 <<std::setw(12)<<m_maxsize
463 <<" |"<<endmsg;
464 out<<"| maxSizeSP | "
465 <<std::setw(12)<<m_maxsizeSP
466 <<" |"<<endmsg;
467 out<<"| pTmin (mev) | "
468 <<std::setw(12)<<std::setprecision(5)<<m_ptmin
469 <<" |"<<endmsg;
470 out<<"| |eta| <= | "
471 <<std::setw(12)<<std::setprecision(5)<<m_etamax
472 <<" |"<<endmsg;
473 out<<"| max radius SP | "
474 <<std::setw(12)<<std::setprecision(5)<<m_r_rmax
475 <<" |"<<endmsg;
476 out<<"| radius step | "
477 <<std::setw(12)<<std::setprecision(5)<<m_r_rstep
478 <<" |"<<endmsg;
479 out<<"| min Z-vertex position | "
480 <<std::setw(12)<<std::setprecision(5)<<m_zmin
481 <<" |"<<endmsg;
482 out<<"| max Z-vertex position | "
483 <<std::setw(12)<<std::setprecision(5)<<m_zmax
484 <<" |"<<endmsg;
485 out<<"| min radius first SP(3) | "
486 <<std::setw(12)<<std::setprecision(5)<<m_r1min
487 <<" |"<<endmsg;
488 out<<"| min radius second SP(3) | "
489 <<std::setw(12)<<std::setprecision(5)<<m_r2min
490 <<" |"<<endmsg;
491 out<<"| min radius last SP(3) | "
492 <<std::setw(12)<<std::setprecision(5)<<m_r3min
493 <<" |"<<endmsg;
494 out<<"| max radius first SP(3) | "
495 <<std::setw(12)<<std::setprecision(4)<<m_r1max
496 <<" |"<<endmsg;
497 out<<"| max radius second SP(3) | "
498 <<std::setw(12)<<std::setprecision(5)<<m_r2max
499 <<" |"<<endmsg;
500 out<<"| max radius last SP(3) | "
501 <<std::setw(12)<<std::setprecision(5)<<m_r3max
502 <<" |"<<endmsg;
503 out<<"| min space points dR | "
504 <<std::setw(12)<<std::setprecision(5)<<m_drmin
505 <<" |"<<endmsg;
506 out<<"| max space points dR | "
507 <<std::setw(12)<<std::setprecision(5)<<m_drmax
508 <<" |"<<endmsg;
509 out<<"| max impact | "
510 <<std::setw(12)<<std::setprecision(5)<<m_diver
511 <<" |"<<endmsg;
512 out<<"| max impact pps | "
513 <<std::setw(12)<<std::setprecision(5)<<m_diverpps
514 <<" |"<<endmsg;
515 out<<"|---------------------------------------------------------------------|"
516 <<endmsg;
517 out<<"| Beam X center | "
518 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[0]
519 <<" |"<<endmsg;
520 out<<"| Beam Y center | "
521 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[0]
522 <<" |"<<endmsg;
523 out<<"| Beam Z center | "
524 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[0]
525 <<" |"<<endmsg;
526 out<<"| Beam X-axis direction | "
527 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[1]
528 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[2]
529 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[3]
530 <<" |"<<endmsg;
531 out<<"| Beam Y-axis direction | "
532 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[1]
533 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[2]
534 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[3]
535 <<" |"<<endmsg;
536 out<<"| Beam Z-axis direction | "
537 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[1]
538 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[2]
539 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[3]
540 <<" |"<<endmsg;
541 out<<"|---------------------------------------------------------------------|"
542 <<endmsg;
543 return out;
544}
545
547// Dumps event information into the MsgStream
549
551{
552 out<<"|---------------------------------------------------------------------|"
553 <<endmsg;
554 out<<"| ns | "
555 <<std::setw(12)<<data.ns
556 <<" |"<<endmsg;
557 out<<"| nsaz | "
558 <<std::setw(12)<<data.nsaz
559 <<" |"<<endmsg;
560 out<<"| seeds | "
561 <<std::setw(12)<<data.l_seeds.size()
562 <<" |"<<endmsg;
563 out<<"|---------------------------------------------------------------------|"
564 <<endmsg;
565 return out;
566}
567
569// Find next set space points
571
573{
574 if (data.endlist) return;
575
576 data.i_seede = data.l_seeds.begin();
577 if (data.mode==0 || data.mode==1) production2Sp(data);
578 else if (data.mode==2 || data.mode==3) production3Sp(data);
579 else if (data.mode==5 || data.mode==6) production3Sp(data);
580
581 data.i_seed = data.l_seeds.begin();
582 ++data.nlist;
583}
584
586// Initiate frame work for seed generator
588
590{
591 m_ptmin = std::max( std::abs(m_ptmin), float(300.*m_fieldScale));
592 m_etamax = std::abs(m_etamax);
593 m_dzdrmax = 1.f/std::tan(2.f*std::atan(std::exp(-m_etamax)));
595 m_COF = 134*.05*9.;
596 m_ipt = 1.f/std::abs(.9f*m_ptmin);
598
599 // Build radius sorted containers
600 //
601 m_r_size = static_cast<int>((m_r_rmax+.1)/m_r_rstep);
602
603 // Build radius-azimuthal sorted containers
604 //
605 constexpr float pi2 = 2.*M_PI;
606 const int NFmax = SizeRF;
607 const float sFmax = static_cast<float>(NFmax)/pi2;
608 const float sFmin = 100./60.;
609
610 m_sF = m_ptmin/m_fieldScale /60.f;
611 if (m_sF >sFmax ) m_sF = sFmax;
612 else if (m_sF < sFmin) m_sF = sFmin;
613 m_fNmax = static_cast<int>(pi2*m_sF);
614 if (m_fNmax >=NFmax) m_fNmax = NFmax-1;
615
616 // Build maps for radius-azimuthal-Z sorted collections
617 //
618 for (int f=0; f<=m_fNmax; ++f) {
619
620 int fb = f-1; if (fb<0 ) fb=m_fNmax;
621 int ft = f+1; if (ft>m_fNmax) ft=0;
622
623 // For each azimuthal region loop through all Z regions
624 //
625 for (int z=0; z<SizeZ; ++z) {
626
627 int a = f *SizeZ+z;
628 int b = fb*SizeZ+z;
629 int c = ft*SizeZ+z;
630 m_rfz_b [a] = 3; m_rfz_t [a] = 3;
631 m_rfz_ib[a][0] = a; m_rfz_it[a][0] = a;
632 m_rfz_ib[a][1] = b; m_rfz_it[a][1] = b;
633 m_rfz_ib[a][2] = c; m_rfz_it[a][2] = c;
634 if (z==5) {
635
636 m_rfz_t [a] = 9; m_rfz_b [a] = 9;
637 m_rfz_it[a][3] = a+1; m_rfz_ib[a][3] = a+1;
638 m_rfz_it[a][4] = b+1; m_rfz_ib[a][4] = b+1;
639 m_rfz_it[a][5] = c+1; m_rfz_ib[a][5] = c+1;
640 m_rfz_it[a][6] = a-1; m_rfz_ib[a][6] = a-1;
641 m_rfz_it[a][7] = b-1; m_rfz_ib[a][7] = b-1;
642 m_rfz_it[a][8] = c-1; m_rfz_ib[a][8] = c-1;
643 } else if (z> 5) {
644
645 m_rfz_b [a] = 6; m_rfz_t [a] = 6;
646 m_rfz_ib[a][3] = a-1; m_rfz_it[a][3] = a-1;
647 m_rfz_ib[a][4] = b-1; m_rfz_it[a][4] = b-1;
648 m_rfz_ib[a][5] = c-1; m_rfz_it[a][5] = c-1;
649
650 if (z<10) {
651
652 m_rfz_t [a] = 9; m_rfz_b [a] = 9;
653 m_rfz_it[a][6] = a+1; m_rfz_ib[a][6] = a+1;
654 m_rfz_it[a][7] = b+1; m_rfz_ib[a][7] = b+1;
655 m_rfz_it[a][8] = c+1; m_rfz_ib[a][8] = c+1;
656 }
657 } else {
658
659 m_rfz_b [a] = 6; m_rfz_t [a] = 6;
660 m_rfz_ib[a][3] = a+1; m_rfz_it[a][3] = a+1;
661 m_rfz_ib[a][4] = b+1; m_rfz_it[a][4] = b+1;
662 m_rfz_ib[a][5] = c+1; m_rfz_it[a][5] = c+1;
663
664 if (z>0) {
665
666 m_rfz_t [a] = 9; m_rfz_b [a] = 9;
667 m_rfz_it[a][6] = a-1; m_rfz_ib[a][6] = a-1;
668 m_rfz_it[a][7] = b-1; m_rfz_ib[a][7] = b-1;
669 m_rfz_it[a][8] = c-1; m_rfz_ib[a][8] = c-1;
670 }
671 }
672 }
673 }
674}
675
677// Initiate beam frame work for seed generator
679
681{
683
684 const Amg::Vector3D &cb = beamSpotHandle->beamPos();
685 double tx = std::tan(beamSpotHandle->beamTilt(0));
686 double ty = std::tan(beamSpotHandle->beamTilt(1));
687
688 double ph = atan2(ty,tx);
689 double th = acos(1./sqrt(1.+tx*tx+ty*ty));
690 double sint = sin(th);
691 double cost = cos(th);
692 double sinp = sin(ph);
693 double cosp = cos(ph);
694
695 data.xbeam[0] = static_cast<float>(cb.x());
696 data.xbeam[1] = static_cast<float>(cost*cosp*cosp+sinp*sinp);
697 data.xbeam[2] = static_cast<float>(cost*sinp*cosp-sinp*cosp);
698 data.xbeam[3] =-static_cast<float>(sint*cosp );
699
700 data.ybeam[0] = static_cast<float>(cb.y());
701 data.ybeam[1] = static_cast<float>(cost*cosp*sinp-sinp*cosp);
702 data.ybeam[2] = static_cast<float>(cost*sinp*sinp+cosp*cosp);
703 data.ybeam[3] =-static_cast<float>(sint*sinp );
704
705 data.zbeam[0] = static_cast<float>(cb.z());
706 data.zbeam[1] = static_cast<float>(sint*cosp);
707 data.zbeam[2] = static_cast<float>(sint*sinp);
708 data.zbeam[3] = static_cast<float>(cost);
709}
710
712// Initiate beam frame work for seed generator
714
716(EventData& data, const Trk::SpacePoint*const& sp,float* r)
717{
718 float x = static_cast<float>(sp->globalPosition().x())-data.xbeam[0];
719 float y = static_cast<float>(sp->globalPosition().y())-data.ybeam[0];
720 float z = static_cast<float>(sp->globalPosition().z())-data.zbeam[0];
721 r[0] = data.xbeam[1]*x+data.xbeam[2]*y+data.xbeam[3]*z;
722 r[1] = data.ybeam[1]*x+data.ybeam[2]*y+data.ybeam[3]*z;
723 r[2] = data.zbeam[1]*x+data.zbeam[2]*y+data.zbeam[3]*z;
724}
725
727// Initiate space points seed maker
729
731{
732 constexpr float pi2 = 2.*M_PI;
733
734 std::vector<InDet::SiSpacePointForSeed*>::iterator r;
735
736 for (int i=0; i!= m_r_size; ++i) {
737
738 if (!data.r_map[i]) continue;
739 r = data.r_Sorted[i].begin();
740
741 while (r!=data.r_Sorted[i].end()) {
742
743 // Azimuthal angle sort
744 //
745 float F = (*r)->phi(); if (F<0.) F+=pi2;
746
747 int f = static_cast<int>(F*m_sF);
748 if (f < 0) f = m_fNmax;
749 else if (f > m_fNmax) f = 0;
750
751 data.rf_Sorted[f].push_back(*r);
752 if (!data.rf_map[f]++) data.rf_index[data.nrf++] = f;
753
754 int z; float Z = (*r)->z();
755
756 // Azimuthal angle and Z-coordinate sort
757 //
758 if (Z>0.) {
759 Z< 250.?z=5:Z< 450.?z=6:Z< 925.?z=7:Z< 1400.?z=8:Z< 2500.?z=9:z=10;
760 } else {
761 Z>-250.?z=5:Z>-450.?z=4:Z>-925.?z=3:Z>-1400.?z=2:Z>-2500.?z=1:z= 0;
762 }
763 int n = f*SizeZ+z;
764 ++data.nsaz;
765 data.rfz_Sorted[n].push_back(*r);
766 if (!data.rfz_map[n]++) data.rfz_index[data.nrfz++] = n;
767 data.r_Sorted[i].erase(r++);
768 }
769 data.r_map[i] = 0;
770 }
771 data.nr = 0;
772 data.state = 0;
773}
774
776// Erase space point information
778
780{
781 for (int i=0; i!=data.nr; ++i) {
782 int n = data.r_index[i];
783 data.r_map[n] = 0;
784 data.r_Sorted[n].erase(data.r_Sorted[n].begin(), data.r_Sorted[n].end());
785 }
786
787 for (int i=0; i!=data.nrf; ++i) {
788 int n = data.rf_index[i];
789 data.rf_map[n] = 0;
790 data.rf_Sorted[n].erase(data.rf_Sorted[n].begin(), data.rf_Sorted[n].end());
791 }
792
793 for (int i=0; i!=data.nrfz; ++i) {
794 int n = data.rfz_index[i];
795 data.rfz_map[n] = 0;
796 data.rfz_Sorted[n].erase(data.rfz_Sorted[n].begin(), data.rfz_Sorted[n].end());
797 }
798
799 data.state = 0;
800 data.ns = 0;
801 data.nsaz = 0;
802 data.nr = 0;
803 data.nrf = 0;
804 data.nrfz = 0;
805}
806
808// 2 space points seeds production
810
815
817// Production 3 space points seeds
819
821{
822 if (data.nsaz<3) return;
823
824 const int ZI[SizeZ]= {5,6,7,8,9,10,4,3,2,1,0};
825 std::vector<InDet::SiSpacePointForSeed*>::iterator rt[9],rte[9],rb[9],rbe[9];
826 int nseed = 0;
827
828 // Loop thorugh all azimuthal regions
829 //
830 for (int f=data.fNmin; f<=m_fNmax; ++f) {
831
832 // For each azimuthal region loop through all Z regions
833 //
834 int z = 0;
835 if (!data.endlist) z = data.zMin;
836
837 for (; z!=SizeZ; ++z) {
838
839 int a = f *SizeZ+ZI[z]; if (!data.rfz_map[a]) continue;
840 int NB = 0, NT = 0;
841 for (int i=0; i!=m_rfz_b[a]; ++i) {
842
843 int an = m_rfz_ib[a][i];
844 if (!data.rfz_map[an]) continue;
845 rb [NB] = data.rfz_Sorted[an].begin();
846 rbe[NB++] = data.rfz_Sorted[an].end();
847 }
848 for (int i=0; i!=m_rfz_t[a]; ++i) {
849
850 int an = m_rfz_it[a][i];
851 if (!data.rfz_map[an]) continue;
852 rt [NT] = data.rfz_Sorted[an].begin();
853 rte[NT++] = data.rfz_Sorted[an].end();
854 }
855 production3Sp(data, rb, rbe, rt, rte, NB, NT, nseed);
856 if (!data.endlist) {
857 data.fNmin = f;
858 data.zMin = z; return;
859 }
860 }
861 }
862 data.endlist = true;
863}
864
866// Production 3 space points seeds (new version)
868
871 std::vector<InDet::SiSpacePointForSeed*>::iterator* rb ,
872 std::vector<InDet::SiSpacePointForSeed*>::iterator* rbe,
873 std::vector<InDet::SiSpacePointForSeed*>::iterator* rt ,
874 std::vector<InDet::SiSpacePointForSeed*>::iterator* rte,
875 int NB, int NT, int& nseed) const
876{
877 std::vector<InDet::SiSpacePointForSeed*>::iterator r0=rb[0],r;
878 if (!data.endlist) {
879 r0 = data.rMin;
880 data.endlist = true;
881 }
882
883 // Loop through all trigger space points
884 //
885 for (; r0!=rbe[0]; ++r0) {
886
887 data.nOneSeeds = 0;
888 data.mapOneSeeds.erase(data.mapOneSeeds.begin(), data.mapOneSeeds.end());
889
890 float R = (*r0)->radius();
891 if (R<m_r2min) continue;
892 if (R>m_r2max) break;
893
894 const Trk::SpacePoint* SP0 = (*r0)->spacepoint;
895
896 bool pix = true;
897 if (SP0->clusterList().second) pix = false;
898 const Trk::Surface* sur0 = (*r0)->sur();
899 float X = (*r0)->x();
900 float Y = (*r0)->y();
901 float Z = (*r0)->z();
902 int Nb = 0;
903
904 // Bottom links production
905 //
906 for (int i=0; i!=NB; ++i) {
907
908 for (r=rb[i]; r!=rbe[i]; ++r) {
909
910 float Rb =(*r)->radius();
911 if (Rb<m_r1min) {rb[i]=r; continue;}
912 if (Rb>m_r1max) break;
913
914 float dR = R-Rb;
915 if (dR<m_drmin) break;
916
917 if (dR > m_drmax || (*r)->sur()==sur0) continue;
918
919 if ( !pix && !(*r)->spacepoint->clusterList().second) continue;
920
921 float Tz = (Z-(*r)->z())/dR;
922
923 if (Tz < m_dzdrmin || Tz > m_dzdrmax) continue;
924
925 // Comparison with vertices Z coordinates
926 //
927 if (pix) {
928 float Zo = Z-R*Tz;
929 if (!isZCompatible(Zo)) continue;
930 }
931 data.SP[Nb] = (*r); if (++Nb==m_maxsizeSP) goto breakb;
932 }
933 }
934 breakb:
935 if (!Nb || Nb==m_maxsizeSP) continue;
936 int Nt = Nb;
937
938 // Top links production
939 //
940 for (int i=0; i!=NT; ++i) {
941
942 for (r=rt[i]; r!=rte[i]; ++r) {
943
944 float Rt =(*r)->radius();
945 float dR = Rt-R;
946 if (dR<m_drmin || Rt<m_r3min) {rt[i]=r; continue;}
947 if (Rt>m_r3max || dR>m_drmax) break;
948
949 if ( (*r)->sur()==sur0) continue;
950
951 float Tz = ((*r)->z()-Z)/dR;
952
953 if (Tz < m_dzdrmin || Tz > m_dzdrmax) continue;
954
955 // Comparison with vertices Z coordinates
956 //
957 if (pix) {
958 float Zo = Z-R*Tz; if (!isZCompatible(Zo)) continue;
959 }
960 data.SP[Nt] = (*r); if (++Nt==m_maxsizeSP) goto breakt;
961 }
962 }
963
964 breakt:
965 if (!(Nt-Nb)) continue;
966
967 float covr0 = (*r0)->covr();
968 float covz0 = (*r0)->covz();
969
970 float ax = X/R;
971 float ay = Y/R;
972
973 for (int i=0; i!=Nt; ++i) {
974
976
977 float dx = sp->x()-X;
978 float dy = sp->y()-Y;
979 float dz = sp->z()-Z;
980 float x = dx*ax+dy*ay;
981 float y =-dx*ay+dy*ax;
982 float r2 = 1.f/(x*x+y*y);
983 float dr = std::sqrt(r2);
984 float tz = dz*dr; if (i < Nb) tz = -tz;
985
986 data.Tz[i] = tz;
987 data.Zo[i] = Z-R*tz;
988 data.R [i] = dr;
989 data.U [i] = x*r2;
990 data.V [i] = y*r2;
991 data.Er[i] = (covz0+sp->covz()+tz*tz*(covr0+sp->covr()))*r2;
992 }
993
994 float imc = m_diver;
995 float imcs = m_diverpps;
996 float ipt2 = m_ipt2;
997 float K = data.K;
998 float K2 = K*K;
999 float COF = m_COF;
1000 float ipt2K = ipt2/K2;
1001 float ipt2C = ipt2*COF;
1002 float COFK = COF*K2;
1003 covr0 *= 2.;
1004 covz0 *= 2.;
1005
1006 // Three space points comparison
1007 //
1008 for (int b=0; b!=Nb; ++b) {
1009
1010 const Trk::SpacePoint* SPb = data.SP[b]->spacepoint;
1011
1012 float Zob = data.Zo[b];
1013 float Tzb = data.Tz[b];
1014 float Rb2r = data.R [b]*covr0;
1015 float Rb2z = data.R [b]*covz0;
1016 float Erb = data.Er[b];
1017 float Vb = data.V [b];
1018 float Ub = data.U [b];
1019 float Tzb2 = (1.f+Tzb*Tzb);
1020 float CSA = Tzb2*COFK;
1021 float ICSA = Tzb2*ipt2C;
1022
1023 for (int t=Nb; t!=Nt; ++t) {
1024
1025 float Ts = .5f*(Tzb+data.Tz[t]);
1026 float dt = Tzb-data.Tz[t];
1027 float dT = dt*dt-Erb-data.Er[t]-data.R[t]*(Ts*Ts*Rb2r+Rb2z);
1028 if ( dT > ICSA) continue;
1029 float dU = data.U[t]-Ub; if (dU == 0. ) continue;
1030 float A = (data.V[t]-Vb)/dU;
1031 float S2 = 1.f+A*A;
1032 float B = Vb-A*Ub;
1033 float B2 = B*B;
1034 if (B2 > ipt2K*S2 || dT*S2 > B2*CSA) continue;
1035 float Im = std::abs((A-B*R)*R);
1036
1037 if (pix) {
1038 if ( Im > imc ) continue;
1039 if (data.SP[t]->spacepoint->clusterList().second && Im > imcs) continue;
1040 }
1041 newOneSeed(data, SPb, SP0, data.SP[t]->spacepoint, Zob, Im);
1042 }
1043 }
1044 nseed += data.mapOneSeeds.size();
1045 fillSeeds(data);
1046 if (nseed>=m_maxsize) {
1047 data.endlist=false;
1048 ++r0;
1049 data.rMin = r0;
1050 return;
1051 }
1052 }
1053}
1054
1056// Test is space point used
1058
1059
1061// New 3 space points seeds from one space points
1063
1065(EventData& data,
1066 const Trk::SpacePoint*& p1,const Trk::SpacePoint*& p2,
1067 const Trk::SpacePoint*& p3,const float& z,const float& q) const
1068{
1069 if (data.nOneSeeds < m_maxOneSize) {
1070 data.OneSeeds[data.nOneSeeds].erase();
1071 data.OneSeeds[data.nOneSeeds].add(p1);
1072 data.OneSeeds[data.nOneSeeds].add(p2);
1073 data.OneSeeds[data.nOneSeeds].add(p3);
1074 data.OneSeeds[data.nOneSeeds].setZVertex(static_cast<double>(z));
1075 data.mapOneSeeds.insert(std::make_pair(q, &(data.OneSeeds[data.nOneSeeds])));
1076 ++data.nOneSeeds;
1077 } else {
1078 std::multimap<float,InDet::SiSpacePointsSeed*>::reverse_iterator
1079 l = data.mapOneSeeds.rbegin();
1080 if ((*l).first <= q) return;
1081 InDet::SiSpacePointsSeed* s = (*l).second;
1082 s->erase();
1083 s->add(p1);
1084 s->add(p2);
1085 s->add(p3);
1086 s->setZVertex(static_cast<double>(z));
1087 std::multimap<float,InDet::SiSpacePointsSeed*>::iterator
1088 i = data.mapOneSeeds.insert(std::make_pair(q, s));
1089
1090 for (++i; i!=data.mapOneSeeds.end(); ++i) {
1091 if ((*i).second==s) {
1092 data.mapOneSeeds.erase(i);
1093 return;
1094 }
1095 }
1096 }
1097}
1098
1100{
1101 if (not data.initialized) initializeEventData(data);
1102
1103 if (data.i_seed==data.i_seede) {
1104 findNext(data);
1105 //cppcheck-suppress identicalInnerCondition
1106 if (data.i_seed==data.i_seede) return nullptr;
1107 }
1108 return &(*data.i_seed++);
1109}
1110
1112{
1113 return Zv > m_zmin && Zv < m_zmax;
1114}
1115
1117// New space point for seeds
1119
1121(EventData& data, const Trk::SpacePoint*const& sp)
1122{
1123 InDet::SiSpacePointForSeed* sps = nullptr;
1124
1125 float r[3];
1127
1128 if (data.i_spforseed!=data.l_spforseed.end()) {
1129 sps = &(*data.i_spforseed++);
1130 sps->set(sp, r);
1131 } else {
1132 data.l_spforseed.emplace_back(sp, r);
1133 sps = &(data.l_spforseed.back());
1134 data.i_spforseed = data.l_spforseed.end();
1135 }
1136
1137 return sps;
1138}
1139
1141// New 2 space points seeds (not used)
1143
1145(EventData& data,
1146 const Trk::SpacePoint*& p1,const Trk::SpacePoint*& p2,
1147 const float& z)
1148{
1149 if (data.i_seede!=data.l_seeds.end()) {
1150 InDet::SiSpacePointsSeed* s = &(*data.i_seede++);
1151 s->erase ( );
1152 s->add (p1);
1153 s->add (p2);
1154 s->setZVertex(static_cast<double>(z));
1155 } else {
1156 data.l_seeds.emplace_back(p1, p2, z);
1157 data.i_seede = data.l_seeds.end();
1158 }
1159}
1160
1162// New 3 space points seeds (not used)
1164
1166(EventData& data,
1167 const Trk::SpacePoint*& p1,const Trk::SpacePoint*& p2,
1168 const Trk::SpacePoint*& p3,const float& z)
1169{
1170 if (data.i_seede!=data.l_seeds.end()) {
1171 InDet::SiSpacePointsSeed* s = &(*data.i_seede++);
1172 s->erase ( );
1173 s->add (p1);
1174 s->add (p2);
1175 s->add (p3);
1176 s->setZVertex(static_cast<double>(z));
1177 } else {
1178 data.l_seeds.emplace_back(p1, p2, p3, z);
1179 data.i_seede = data.l_seeds.end();
1180 }
1181}
1182
1184// Fill seeds
1186
1188{
1189 std::multimap<float,InDet::SiSpacePointsSeed*>::iterator
1190 l = data.mapOneSeeds.begin(),
1191 le = data.mapOneSeeds.end ();
1192
1193 for (; l!=le; ++l) {
1194 if (data.i_seede!=data.l_seeds.end()) {
1195 InDet::SiSpacePointsSeed* s = &(*data.i_seede++);
1196 *s = *(*l).second;
1197 } else {
1198 data.l_seeds.emplace_back(*(*l).second);
1199 data.i_seede = data.l_seeds.end();
1200 }
1201 }
1202}
1203
1205 data.initialize(EventData::ToolType::BeamGas,
1208 0, // maxsize not used
1209 m_r_size,
1210 SizeRF,
1211 SizeRFZ,
1212 0, // sizeRFZV not used
1213 false); // checkEta not used
1214}
1215
1218
#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 >)
static void convertToBeamFrameWork(EventData &data, const Trk::SpacePoint *const &sp, float *r)
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
virtual void newRegion(const EventContext &ctx, EventData &data, const std::vector< IdentifierHash > &vPixel, const std::vector< IdentifierHash > &vSCT) const override
virtual void find2Sp(EventData &data, const std::list< Trk::Vertex > &lv) const override
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCondObjInputKey
virtual void newEvent(const EventContext &ctx, EventData &data, int iteration) const override
virtual void writeNtuple(const SiSpacePointsSeed *seed, const Trk::Track *track, int seedType, long EventNumber) const override
virtual MsgStream & dump(EventData &data, MsgStream &out) 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 SiSpacePointForSeed * newSpacePoint(EventData &data, const Trk::SpacePoint *const &)
static MsgStream & dumpEvent(EventData &data, MsgStream &out)
SG::ReadHandleKey< SpacePointContainer > m_spacepointsSCT
void newOneSeed(EventData &data, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const float &, const float &) const
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_prdToTrackMap
SG::ReadHandleKey< SpacePointContainer > m_spacepointsPixel
MsgStream & dumpConditions(EventData &data, MsgStream &out) const
virtual const SiSpacePointsSeed * next(const EventContext &ctx, EventData &data) const override
bool isUsed(const Trk::SpacePoint *sp, const Trk::PRDtoTrackMap &prd_to_track_map) const
SG::ReadHandleKey< SpacePointOverlapCollection > m_spacepointsOverlap
static void newSeed(EventData &data, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const float &)
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,...
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.
const std::pair< const PrepRawData *, const PrepRawData * > & clusterList() const
return the pair of cluster pointers by reference
Abstract Base Class for tracking surfaces.
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