ATLAS Offline Software
Loading...
Searching...
No Matches
SiSpacePointsSeedMaker_HeavyIon.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_HeavyIon
8// (c) ATLAS Detector software
10// AlgTool used for TRT_DriftCircleOnTrack object production
12// Version 1.0 21/04/2004 I.Gavrilenko
14
16#include "TrkTrack/Track.h"
18
19#include <cmath>
20
21#include <iomanip>
22#include <ostream>
23
24#include <TTree.h>
25
27// Constructor
29
31(const std::string& t, const std::string& n, const IInterface* p)
32 : base_class(t, n, p)
33{
34}
35
37// Initialisation
39
41{
42 StatusCode sc = AlgTool::initialize();
43 ATH_CHECK( m_prdToTrackMap.initialize( !m_prdToTrackMap.key().empty()));
44
46 ATH_CHECK(m_spacepointsSCT.initialize(m_sct));
48
49 // Get beam geometry
50 //
51 ATH_CHECK(m_beamSpotKey.initialize());
52
53 ATH_CHECK( m_fieldCondObjInputKey.initialize());
54
55 // Build framework
56 //
58
59 // Get output print level
60 //
61 m_outputlevel = msg().level()-MSG::DEBUG;
62 if (m_outputlevel<=0) {
63 EventData data;
65 data.nprint=0;
66 dump(data, msg(MSG::DEBUG));
67 }
68
69 m_initialized = true;
70
71 if (m_writeNtuple) {
72 ATH_CHECK( m_thistSvc.retrieve() );
73
74 m_treeName = (std::string("SeedTree_")+name());
75 std::replace( m_treeName.begin(), m_treeName.end(), '.', '_' );
76
77 m_outputTree = new TTree( m_treeName.c_str() , "SeedMakerValTool");
78
79 m_outputTree->Branch("eventNumber", &m_eventNumber);
80 m_outputTree->Branch("d0", &m_d0);
81 m_outputTree->Branch("z0", &m_z0);
82 m_outputTree->Branch("pt", &m_pt);
83 m_outputTree->Branch("eta", &m_eta);
84 m_outputTree->Branch("x1", &m_x1);
85 m_outputTree->Branch("x2", &m_x2);
86 m_outputTree->Branch("x3", &m_x3);
87 m_outputTree->Branch("y1", &m_y1);
88 m_outputTree->Branch("y2", &m_y2);
89 m_outputTree->Branch("y3", &m_y3);
90 m_outputTree->Branch("z1", &m_z1);
91 m_outputTree->Branch("z2", &m_z2);
92 m_outputTree->Branch("z3", &m_z3);
93 m_outputTree->Branch("r1", &m_r1);
94 m_outputTree->Branch("r2", &m_r2);
95 m_outputTree->Branch("r3", &m_r3);
96 m_outputTree->Branch("quality", &m_quality);
97 m_outputTree->Branch("seedType", &m_type);
98 m_outputTree->Branch("givesTrack", &m_givesTrack);
99 m_outputTree->Branch("dzdr_b", &m_dzdr_b);
100 m_outputTree->Branch("dzdr_t", &m_dzdr_t);
101 m_outputTree->Branch("dr_b", &m_dr_b);
102 m_outputTree->Branch("dr_t", &m_dr_t);
103 m_outputTree->Branch("track_pt", &m_trackPt);
104 m_outputTree->Branch("track_eta", &m_trackEta);
105
106 TString fullTreeName = m_treeFolder + m_treeName;
107 ATH_CHECK( m_thistSvc->regTree( fullTreeName.Data(), m_outputTree ) );
108 }
109
110 return sc;
111}
112
114// Finalize
116
118{
119 return AlgTool::finalize();
120}
121
123// Initialize tool for new event
125
126void InDet::SiSpacePointsSeedMaker_HeavyIon::newEvent(const EventContext& ctx, EventData& data, int) const
127{
128 if (not data.initialized) initializeEventData(data);
129
130 data.trigger = false;
131 if (!m_pixel && !m_sct) return;
132 erase(data);
133 buildBeamFrameWork(ctx, data);
134
135 double f[3], gP[3] ={10.,10.,0.};
136
137 MagField::AtlasFieldCache fieldCache;
138
139 // Get field cache object
141 const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
142 if (fieldCondObj == nullptr) {
143 ATH_MSG_ERROR("SiSpacePointsSeedMaker_HeavyIon: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCondObjInputKey.key());
144 return;
145 }
146 fieldCondObj->getInitializedCache (fieldCache);
147
148 if (fieldCache.solenoidOn()) {
149 fieldCache.getFieldZR(gP,f);
150
151 data.K = 2./(300.*f[2]);
152 } else {
153 data.K = 2./(300.* 5. );
154 }
155
156 data.i_spforseed = data.l_spforseed.begin();
157
158 float irstep = 1./m_r_rstep;
159 int irmax = m_r_size-1 ;
160
162 const Trk::PRDtoTrackMap *prd_to_track_map_cptr = nullptr;
163 if (not m_prdToTrackMap.key().empty()) {
165 if (!prd_to_track_map.isValid()) {
166 ATH_MSG_ERROR("Failed to read PRD to track association map: " << m_prdToTrackMap.key());
167 }
168 prd_to_track_map_cptr = prd_to_track_map.cptr();
169 }
170
171 // Get pixels space points containers from store gate
172 //
173 if (m_pixel) {
174
176 if (spacepointsPixel.isValid()) {
177
178 for (const SpacePointCollection* spc: *spacepointsPixel) {
179 for (const Trk::SpacePoint* sp: *spc) {
180 float r = sp->r();
181 if (r<m_r_rmin || r>=m_r_rmax) continue;
182 if (prd_to_track_map_cptr and isUsed(sp,*prd_to_track_map_cptr)) continue;
184 int ir = static_cast<int>(sps->radius()*irstep);
185 if (ir>irmax) ir = irmax;
186 data.r_Sorted[ir].push_back(sps);
187 ++data.r_map[ir];
188 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
189 ++data.ns;
190 }
191 }
192 }
193 }
194
195 // Get sct space points containers from store gate
196 //
197 if (m_sct) {
198
200 if (spacepointsSCT.isValid()) {
201
202 for (const SpacePointCollection* spc: *spacepointsSCT) {
203 for (const Trk::SpacePoint* sp: *spc) {
204 float r = sp->r();
205 if (r<m_r_rmin || r>=m_r_rmax) continue;
206 if (prd_to_track_map_cptr and isUsed(sp,*prd_to_track_map_cptr)) continue;
208 int ir = static_cast<int>(sps->radius()*irstep);
209 if (ir>irmax) ir = irmax;
210 data.r_Sorted[ir].push_back(sps);
211 ++data.r_map[ir];
212 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
213 ++data.ns;
214 }
215 }
216 }
217 }
218
219 if (m_useOverlap && !data.checketa) {
221 if (spacepointsOverlap.isValid()) {
222 for (const Trk::SpacePoint* sp: *spacepointsOverlap) {
224 float r = sp->r();
225 if (r<m_r_rmin || r>=m_r_rmax) continue;
226 if (prd_to_track_map_cptr && isUsed(sp, *prd_to_track_map_cptr)) continue;
227
230 if (!sps) continue;
231
232 int ir = static_cast<int>(sps->radius()*irstep);
233 if (ir>irmax) ir = irmax;
234 data.r_Sorted[ir].push_back(sps);
235 ++data.r_map[ir];
236 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
237 ++data.ns;
238 }
239 }
240 }
241
242 fillLists(data);
243}
244
246// Initialize tool for new region
248
250(const EventContext& ctx, EventData& data,
251 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT) const
252{
253 if (not data.initialized) initializeEventData(data);
254
255 data.trigger = false;
256 if (!m_pixel && !m_sct) return;
257 erase(data);
258
259 buildBeamFrameWork(ctx, data);
260
261 double f[3], gP[3] ={10.,10.,0.};
262
263 MagField::AtlasFieldCache fieldCache;
264
265 // Get field cache object
267 const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
268 if (fieldCondObj == nullptr) {
269 ATH_MSG_ERROR("SiSpacePointsSeedMaker_HeavyIon: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCondObjInputKey.key());
270 return;
271 }
272 fieldCondObj->getInitializedCache (fieldCache);
273
274 if (fieldCache.solenoidOn()) {
275 fieldCache.getFieldZR(gP, f);
276
277 data.K = 2./(300.*f[2]);
278 } else {
279 data.K = 2./(300.* 5.);
280 }
281
282 data.i_spforseed = data.l_spforseed.begin();
283
284 float irstep = 1./m_r_rstep;
285 int irmax = m_r_size-1;
286
287 // Get pixels space points containers from store gate
288 //
289 if (m_pixel && !vPixel.empty()) {
290
292 if (spacepointsPixel.isValid()) {
293
294 // Loop through all trigger collections
295 //
296 for (const IdentifierHash& l: vPixel) {
297 const auto *w = spacepointsPixel->indexFindPtr(l);
298 if (w==nullptr) continue;
299 for (const Trk::SpacePoint* sp: *w) {
300 float r = sp->r();
301 if (r<0. || r>=m_r_rmax) continue;
303 int ir = static_cast<int>(sps->radius()*irstep);
304 if (ir>irmax) ir = irmax;
305 data.r_Sorted[ir].push_back(sps);
306 ++data.r_map[ir];
307 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
308 ++data.ns;
309 }
310 }
311 }
312 }
313
314 // Get sct space points containers from store gate
315 //
316 if (m_sct && !vSCT.empty()) {
317
319 if (spacepointsSCT.isValid()) {
320
321 // Loop through all trigger collections
322 //
323 for (const IdentifierHash& l: vSCT) {
324 const auto *w = spacepointsSCT->indexFindPtr(l);
325 if (w==nullptr) continue;
326 for (const Trk::SpacePoint* sp: *w) {
327 float r = sp->r();
328 if (r<0. || r>=m_r_rmax) continue;
330 int ir = static_cast<int>(sps->radius()*irstep);
331 if (ir>irmax) ir = irmax;
332 data.r_Sorted[ir].push_back(sps);
333 ++data.r_map[ir];
334 if (data.r_map[ir]==1) data.r_index[data.nr++] = ir;
335 ++data.ns;
336 }
337 }
338 }
339 }
340 fillLists(data);
341}
342
344// Initialize tool for new region
346
348(const EventContext& ctx, EventData& data,
349 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT,
350 const IRoiDescriptor&) const
351{
352 newRegion(ctx, data, vPixel, vSCT);
353}
354
356// Methods to initilize different strategies of seeds production
357// with two space points with or without vertex constraint
359
360void InDet::SiSpacePointsSeedMaker_HeavyIon::find2Sp(EventData& data, const std::list<Trk::Vertex>& lv) const
361{
362 if (not data.initialized) initializeEventData(data);
363
364 data.izvertex = not lv.empty();
365
366 int mode = 0;
367 if (lv.begin()!=lv.end()) mode = 1;
368 bool newv = newVertices(data, lv);
369
370 if (newv || !data.state || data.nspoint!=2 || data.mode!=mode || data.nlist) {
371
372 data.i_seede = data.l_seeds.begin();
373 data.state = 1 ;
374 data.nspoint = 2 ;
375 data.nlist = 0 ;
376 data.mode = mode;
377 data.endlist = true;
378 data.fvNmin = 0 ;
379 data.fNmin = 0 ;
380 data.zMin = 0 ;
381 production2Sp(data);
382 }
383 data.i_seed = data.l_seeds.begin();
384
385 if (m_outputlevel<=0) {
386 data.nprint=1;
387 dump(data, msg(MSG::DEBUG));
388 }
389}
390
392// Methods to initilize different strategies of seeds production
393// with three space points with or without vertex constraint
395
396void InDet::SiSpacePointsSeedMaker_HeavyIon::find3Sp(const EventContext&, EventData& data, const std::list<Trk::Vertex>& lv) const
397{
398 if (not data.initialized) initializeEventData(data);
399
400 data.izvertex = not lv.empty();
401
402 int mode = 2;
403 if (lv.begin()!=lv.end()) mode = 3;
404 bool newv = newVertices(data, lv);
405
406 if (newv || !data.state || data.nspoint!=3 || data.mode!=mode || data.nlist) {
407
408 data.i_seede = data.l_seeds.begin();
409 data.state = 1 ;
410 data.nspoint = 3 ;
411 data.nlist = 0 ;
412 data.mode = mode ;
413 data.endlist = true ;
414 data.fvNmin = 0 ;
415 data.fNmin = 0 ;
416 data.zMin = 0 ;
417 production3Sp(data);
418 }
419 data.i_seed = data.l_seeds.begin();
420
421 if (m_outputlevel<=0) {
422 data.nprint=1;
423 dump(data, msg(MSG::DEBUG));
424 }
425}
426
427void InDet::SiSpacePointsSeedMaker_HeavyIon::find3Sp(const EventContext& ctx, EventData& data, const std::list<Trk::Vertex>& lv, const double*) const
428{
429 find3Sp(ctx, data, lv);
430}
431
433// Methods to initilize different strategies of seeds production
434// with variable number space points with or without vertex constraint
435// Variable means (2,3,4,....) any number space points
437
438void InDet::SiSpacePointsSeedMaker_HeavyIon::findVSp(const EventContext&, EventData& data, const std::list<Trk::Vertex>& lv) const
439{
440 if (not data.initialized) initializeEventData(data);
441
442 int mode = 5;
443 if (lv.begin()!=lv.end()) mode = 6;
444 bool newv = newVertices(data, lv);
445
446 if (newv || !data.state || data.nspoint!=4 || data.mode!=mode || data.nlist) {
447 data.i_seede = data.l_seeds.begin();
448 data.state = 1 ;
449 data.nspoint = 4 ;
450 data.nlist = 0 ;
451 data.mode = mode ;
452 data.endlist = true ;
453 data.fvNmin = 0 ;
454 data.fNmin = 0 ;
455 data.zMin = 0 ;
456 production3Sp(data);
457 }
458 data.i_seed = data.l_seeds.begin();
459
460 if (m_outputlevel<=0) {
461 data.nprint=1;
462 dump(data, msg(MSG::DEBUG));
463 }
464}
465
467// Dumps relevant information into the MsgStream
469
470MsgStream& InDet::SiSpacePointsSeedMaker_HeavyIon::dump(EventData& data, MsgStream& out) const
471{
472 if (not data.initialized) initializeEventData(data);
473
474 if (data.nprint) return dumpEvent(data, out);
475 return dumpConditions(data, out);
476}
477
479// Dumps conditions information into the MsgStream
481
483{
484 int n = 42-m_spacepointsPixel.key().size();
485 std::string s2; for (int i=0; i<n; ++i) s2.append(" "); s2.append("|");
486 n = 42-m_spacepointsSCT.key().size();
487 std::string s3; for (int i=0; i<n; ++i) s3.append(" "); s3.append("|");
488 n = 42-m_spacepointsOverlap.key().size();
489 std::string s4; for (int i=0; i<n; ++i) s4.append(" "); s4.append("|");
490 n = 42-m_beamSpotKey.key().size();
491 std::string s5; for (int i=0; i<n; ++i) s5.append(" "); s5.append("|");
492
493
494 out<<"|---------------------------------------------------------------------|"
495 <<endmsg;
496 out<<"| Pixel space points | "<<m_spacepointsPixel.key() <<s2
497 <<endmsg;
498 out<<"| SCT space points | "<<m_spacepointsSCT.key()<<s3
499 <<endmsg;
500 out<<"| Overlap space points | "<<m_spacepointsOverlap.key()<<s4
501 <<endmsg;
502 out<<"| BeamConditionsService | "<<m_beamSpotKey.key()<<s5
503 <<endmsg;
504 out<<"| usePixel | "
505 <<std::setw(12)<<m_pixel
506 <<" |"<<endmsg;
507 out<<"| useSCT | "
508 <<std::setw(12)<<m_sct
509 <<" |"<<endmsg;
510 out<<"| maxSize | "
511 <<std::setw(12)<<m_maxsize
512 <<" |"<<endmsg;
513 out<<"| maxSizeSP | "
514 <<std::setw(12)<<m_maxsizeSP
515 <<" |"<<endmsg;
516 out<<"| pTmin (mev) | "
517 <<std::setw(12)<<std::setprecision(5)<<m_ptmin
518 <<" |"<<endmsg;
519 out<<"| pTmax (mev) | "
520 <<std::setw(12)<<std::setprecision(5)<<m_ptmax
521 <<" |"<<endmsg;
522 out<<"| |eta| <= | "
523 <<std::setw(12)<<std::setprecision(5)<<m_etamax
524 <<" |"<<endmsg;
525 out<<"| max radius SP | "
526 <<std::setw(12)<<std::setprecision(5)<<m_r_rmax
527 <<" |"<<endmsg;
528 out<<"| radius step | "
529 <<std::setw(12)<<std::setprecision(5)<<m_r_rstep
530 <<" |"<<endmsg;
531 out<<"| min Z-vertex position | "
532 <<std::setw(12)<<std::setprecision(5)<<m_zmin
533 <<" |"<<endmsg;
534 out<<"| max Z-vertex position | "
535 <<std::setw(12)<<std::setprecision(5)<<m_zmax
536 <<" |"<<endmsg;
537 out<<"| min radius first SP(2) | "
538 <<std::setw(12)<<std::setprecision(5)<<m_r1minv
539 <<" |"<<endmsg;
540 out<<"| min radius second SP(2) | "
541 <<std::setw(12)<<std::setprecision(5)<<m_r2minv
542 <<" |"<<endmsg;
543 out<<"| max radius first SP(2) | "
544 <<std::setw(12)<<std::setprecision(5)<<m_r1maxv
545 <<" |"<<endmsg;
546 out<<"| max radius second SP(2) | "
547 <<std::setw(12)<<std::setprecision(5)<<m_r2maxv
548 <<" |"<<endmsg;
549 out<<"| min space points dR (b) | "
550 <<std::setw(12)<<std::setprecision(5)<<m_drmin_b
551 <<" |"<<endmsg;
552 out<<"| min space points dR (t) | "
553 <<std::setw(12)<<std::setprecision(5)<<m_drmin_t
554 <<" |"<<endmsg;
555 out<<"| max space points dR | "
556 <<std::setw(12)<<std::setprecision(5)<<m_drmax
557 <<" |"<<endmsg;
558 out<<"| max dZ impact | "
559 <<std::setw(12)<<std::setprecision(5)<<m_dzver
560 <<" |"<<endmsg;
561 out<<"| max dZ/dR impact | "
562 <<std::setw(12)<<std::setprecision(5)<<m_dzdrver
563 <<" |"<<endmsg;
564 out<<"| max impact | "
565 <<std::setw(12)<<std::setprecision(5)<<m_diver
566 <<" |"<<endmsg;
567 out<<"| max impact pps | "
568 <<std::setw(12)<<std::setprecision(5)<<m_diverpps
569 <<" |"<<endmsg;
570 out<<"| max impact sss | "
571 <<std::setw(12)<<std::setprecision(5)<<m_diversss
572 <<" |"<<endmsg;
573 out<<"|---------------------------------------------------------------------|"
574 <<endmsg;
575 out<<"| Beam X center | "
576 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[0]
577 <<" |"<<endmsg;
578 out<<"| Beam Y center | "
579 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[0]
580 <<" |"<<endmsg;
581 out<<"| Beam Z center | "
582 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[0]
583 <<" |"<<endmsg;
584 out<<"| Beam X-axis direction | "
585 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[1]
586 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[2]
587 <<std::setw(12)<<std::setprecision(5)<<data.xbeam[3]
588 <<" |"<<endmsg;
589 out<<"| Beam Y-axis direction | "
590 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[1]
591 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[2]
592 <<std::setw(12)<<std::setprecision(5)<<data.ybeam[3]
593 <<" |"<<endmsg;
594 out<<"| Beam Z-axis direction | "
595 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[1]
596 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[2]
597 <<std::setw(12)<<std::setprecision(5)<<data.zbeam[3]
598 <<" |"<<endmsg;
599 out<<"|---------------------------------------------------------------------|"
600 <<endmsg;
601 return out;
602}
603
605// Dumps event information into the MsgStream
607
609{
610 out<<"|---------------------------------------------------------------------|"
611 <<endmsg;
612 out<<"| data.ns | "
613 <<std::setw(12)<<data.ns
614 <<" |"<<endmsg;
615 out<<"| data.nsaz | "
616 <<std::setw(12)<<data.nsaz
617 <<" |"<<endmsg;
618 out<<"| data.nsazv | "
619 <<std::setw(12)<<data.nsazv
620 <<" |"<<endmsg;
621 out<<"| seeds | "
622 <<std::setw(12)<<data.l_seeds.size()
623 <<" |"<<endmsg;
624 out<<"|---------------------------------------------------------------------|"
625 <<endmsg;
626 return out;
627}
628
630// Find next set space points
632
634{
635 if (data.endlist) return;
636
637 data.i_seede = data.l_seeds.begin();
638 if (data.mode==0 || data.mode==1) production2Sp(data);
639 else if (data.mode==2 || data.mode==3) production3Sp(data);
640 else if (data.mode==5 || data.mode==6) production3Sp(data);
641
642 data.i_seed = data.l_seeds.begin();
643 ++data.nlist;
644}
645
647// New and old list vertices comparison
649
650bool InDet::SiSpacePointsSeedMaker_HeavyIon::newVertices(EventData& data, const std::list<Trk::Vertex>& lV) const
651{
652 unsigned int s1 = data.l_vertex.size();
653 unsigned int s2 = lV.size();
654
655 if (s1==0 && s2==0) return false;
656
657 data.l_vertex.clear();
658
659 for (const Trk::Vertex& v: lV) {
660 data.l_vertex.insert(static_cast<float>(v.position().z()));
661 if (data.l_vertex.size() >= m_maxNumberVertices) break;
662 }
663 return false;
664}
665
667// Initiate frame work for seed generator
669
671{
672 m_ptmin = std::max( std::abs(m_ptmin), float(100.*m_fieldScale));
673 m_etamax = std::abs(m_etamax) ;
674 m_dzdrmax = 1.f/std::tan(2.f*std::atan(exp(-m_etamax)));
676 m_COF = 134*.05*9. ;
677 m_ipt = 1.f/std::abs(.9f*m_ptmin) ;
678 m_iptmax = m_ptmax == std::numeric_limits<float>::max()
679 ? 0.f
680 : 1.f/std::abs(1.1f*m_ptmax);
681 m_ipt2 = m_ipt*m_ipt ;
682
683 // Build radius sorted containers
684 //
685 m_r_size = static_cast<int>((m_r_rmax+.1)/m_r_rstep);
686
687 // Build radius-azimuthal sorted containers
688 //
689 constexpr float pi2 = 2.*M_PI;
690 const int NFmax = SizeRF;
691 const float sFmax = static_cast<float>(NFmax)/pi2;
692 const float sFmin = 100./60.;
693
695 if (m_sF > sFmax ) m_sF = sFmax;
696 else if (m_sF < sFmin) m_sF = sFmin;
697 m_fNmax = static_cast<int>(pi2*m_sF);
698 if (m_fNmax >=NFmax) m_fNmax = NFmax-1;
699
700 // Build radius-azimuthal-Z sorted containers for Z-vertices
701 //
702 const int NFtmax = SizeRFV;
703 const float sFvmax = static_cast<float>(NFtmax)/pi2;
704 m_sFv = m_ptmin/m_fieldScale /120.f;
705 if (m_sFv > sFvmax) m_sFv = sFvmax;
706 m_fvNmax = static_cast<int>(pi2*m_sFv);
707 if (m_fvNmax>=NFtmax) m_fvNmax = NFtmax-1;
708
709 // Build maps for radius-azimuthal-Z sorted collections
710 //
711 for (int f=0; f<=m_fNmax; ++f) {
712 int fb = f-1;
713 if (fb<0) fb = m_fNmax;
714 int ft = f+1;
715 if (ft>m_fNmax) ft = 0;
716
717 // For each azimuthal region loop through all Z regions
718 //
719 for (int z=0; z<SizeZ; ++z) {
720 int a = f *SizeZ+z;
721 int b = fb*SizeZ+z;
722 int c = ft*SizeZ+z;
723 m_rfz_b [a] = 3; m_rfz_t [a] = 3;
724 m_rfz_ib[a][0] = a; m_rfz_it[a][0] = a;
725 m_rfz_ib[a][1] = b; m_rfz_it[a][1] = b;
726 m_rfz_ib[a][2] = c; m_rfz_it[a][2] = c;
727 if (z==5) {
728 m_rfz_t [a] = 9 ;
729 m_rfz_it[a][3] = a+1;
730 m_rfz_it[a][4] = b+1;
731 m_rfz_it[a][5] = c+1;
732 m_rfz_it[a][6] = a-1;
733 m_rfz_it[a][7] = b-1;
734 m_rfz_it[a][8] = c-1;
735 } else if (z> 5) {
736 m_rfz_b [a] = 6 ;
737 m_rfz_ib[a][3] = a-1;
738 m_rfz_ib[a][4] = b-1;
739 m_rfz_ib[a][5] = c-1;
740 if (z<10) {
741 m_rfz_t [a] = 6 ;
742 m_rfz_it[a][3] = a+1;
743 m_rfz_it[a][4] = b+1;
744 m_rfz_it[a][5] = c+1;
745 }
746 } else {
747 m_rfz_b [a] = 6 ;
748 m_rfz_ib[a][3] = a+1;
749 m_rfz_ib[a][4] = b+1;
750 m_rfz_ib[a][5] = c+1;
751 if (z>0) {
752 m_rfz_t [a] = 6 ;
753 m_rfz_it[a][3] = a-1;
754 m_rfz_it[a][4] = b-1;
755 m_rfz_it[a][5] = c-1;
756 }
757 }
758 if (z==3) {
759 m_rfz_b[a] = 9;
760 m_rfz_ib[a][6] = a+2;
761 m_rfz_ib[a][7] = b+2;
762 m_rfz_ib[a][8] = c+2;
763 } else if (z==7) {
764 m_rfz_b[a] = 9;
765 m_rfz_ib[a][6] = a-2;
766 m_rfz_ib[a][7] = b-2;
767 m_rfz_ib[a][8] = c-2;
768 }
769 }
770 }
771
772 // Build maps for radius-azimuthal-Z sorted collections for Z
773 //
774 for (int f=0; f<=m_fvNmax; ++f) {
775 int fb = f-1; if (fb<0 ) fb=m_fvNmax;
776 int ft = f+1; if (ft>m_fvNmax) ft=0;
777
778 // For each azimuthal region loop through central Z regions
779 //
780 for (int z=0; z<SizeZV; ++z) {
781 int a = f *SizeZV+z;
782 int b = fb*SizeZV+z;
783 int c = ft*SizeZV+z;
784 m_rfzv_n[a] = 3;
785 m_rfzv_i[a][0] = a;
786 m_rfzv_i[a][1] = b;
787 m_rfzv_i[a][2] = c;
788 if (z>1) {
789 m_rfzv_n[a] = 6;
790 m_rfzv_i[a][3] = a-1;
791 m_rfzv_i[a][4] = b-1;
792 m_rfzv_i[a][5] = c-1;
793 } else if (z<1) {
794 m_rfzv_n[a] = 6;
795 m_rfzv_i[a][3] = a+1;
796 m_rfzv_i[a][4] = b+1;
797 m_rfzv_i[a][5] = c+1;
798 }
799 }
800 }
801}
802
804// Initiate beam frame work for seed generator
806
808{
810
811 const Amg::Vector3D& cb = beamSpotHandle->beamPos();
812 double tx = std::tan(beamSpotHandle->beamTilt(0));
813 double ty = std::tan(beamSpotHandle->beamTilt(1));
814
815 double ph = atan2(ty,tx);
816 double th = acos(1./sqrt(1.+tx*tx+ty*ty));
817 double sint = sin(th);
818 double cost = cos(th);
819 double sinp = sin(ph);
820 double cosp = cos(ph);
821
822 data.xbeam[0] = static_cast<float>(cb.x()) ;
823 data.xbeam[1] = static_cast<float>(cost*cosp*cosp+sinp*sinp);
824 data.xbeam[2] = static_cast<float>(cost*sinp*cosp-sinp*cosp);
825 data.xbeam[3] =-static_cast<float>(sint*cosp );
826
827 data.ybeam[0] = static_cast<float>(cb.y()) ;
828 data.ybeam[1] = static_cast<float>(cost*cosp*sinp-sinp*cosp);
829 data.ybeam[2] = static_cast<float>(cost*sinp*sinp+cosp*cosp);
830 data.ybeam[3] =-static_cast<float>(sint*sinp );
831
832 data.zbeam[0] = static_cast<float>(cb.z()) ;
833 data.zbeam[1] = static_cast<float>(sint*cosp) ;
834 data.zbeam[2] = static_cast<float>(sint*sinp) ;
835 data.zbeam[3] = static_cast<float>(cost) ;
836}
837
839// Initiate beam frame work for seed generator
841
843(EventData& data, const Trk::SpacePoint*const& sp,std::array<float, 3>& r)
844{
845 r[0] = static_cast<float>(sp->globalPosition().x())-data.xbeam[0];
846 r[1] = static_cast<float>(sp->globalPosition().y())-data.ybeam[0];
847 r[2] = static_cast<float>(sp->globalPosition().z())-data.zbeam[0];
848}
849
851// Initiate space points seed maker
853
855{
856 constexpr float pi2 = 2.*M_PI;
857 std::vector<InDet::SiSpacePointForSeed*>::iterator r;
858
859 for (int i=0; i<m_r_size; ++i) {
860 if (!data.r_map[i]) continue;
861 r = data.r_Sorted[i].begin();
862
863 while (r!=data.r_Sorted[i].end()) {
864
865 // Azimuthal angle sort
866 //
867 float F = (*r)->phi();
868 if (F<0.) F+=pi2;
869
870 int f = static_cast<int>(F*m_sF);
871 if (f < 0) f = m_fNmax;
872 else if (f > m_fNmax) f = 0;
873
874 int z;
875 float Z = (*r)->z();
876
877 // Azimuthal angle and Z-coordinate sort
878 //
879 if (Z>0.) {
880 Z< 250.?z=5:Z< 450.?z=6:Z< 925.?z=7:Z< 1400.?z=8:Z< 2500.?z=9:z=10;
881 } else {
882 Z>-250.?z=5:Z>-450.?z=4:Z>-925.?z=3:Z>-1400.?z=2:Z>-2500.?z=1:z= 0;
883 }
884 int n = f*SizeZ+z;
885 ++data.nsaz;
886 data.rfz_Sorted[n].push_back(*r);
887 if (!data.rfz_map[n]++) data.rfz_index[data.nrfz++] = n;
888
889 if ((*r)->spacepoint->clusterList().second == 0 && z>=3 && z<=7) {
890 z<=4 ? z=0 : z>=6 ? z=2 : z=1;
891
892 // Azimuthal angle and Z-coordinate sort for fast vertex search
893 //
894 f = static_cast<int>(F*m_sFv);
895 if (f < 0) f += m_fvNmax;
896 else if (f> m_fvNmax) f -= m_fvNmax;
897 n = f*SizeZV+z;
898 ++data.nsazv;
899 data.rfzv_Sorted[n].push_back(*r);
900 if (!data.rfzv_map[n]++) data.rfzv_index[data.nrfzv++] = n;
901 }
902 r = data.r_Sorted[i].erase(r);
903 }
904 data.r_map[i] = 0;
905 }
906 data.nr = 0;
907 data.state = 0;
908}
909
911// Erase space point information
913
915{
916 for (int i=0; i<data.nr; ++i) {
917 int n = data.r_index[i];
918 data.r_map[n] = 0;
919 data.r_Sorted[n].clear();
920 }
921
922 for (int i=0; i<data.nrfz; ++i) {
923 int n = data.rfz_index[i];
924 data.rfz_map[n] = 0;
925 data.rfz_Sorted[n].clear();
926 }
927
928 for (int i=0; i<data.nrfzv; ++i) {
929 int n = data.rfzv_index[i];
930 data.rfzv_map[n] = 0;
931 data.rfzv_Sorted[n].clear();
932 }
933 data.state = 0;
934 data.ns = 0;
935 data.nsaz = 0;
936 data.nsazv = 0;
937 data.nr = 0;
938 data.nrfz = 0;
939 data.nrfzv = 0;
940}
941
943// 2 space points seeds production
945
947{
948 if (data.nsazv<2) return;
949
950 std::vector<InDet::SiSpacePointForSeed*>::iterator r0,r0e,r,re;
951 int nseed = 0;
952
953 // Loop through all azimuthal regions
954 //
955 for (int f=data.fvNmin; f<=m_fvNmax; ++f) {
956
957 // For each azimuthal region loop through Z regions
958 //
959 int z = 0;
960 if (!data.endlist) z = data.zMin;
961 for (; z<SizeZV; ++z) {
962 int a = f*SizeZV+z;
963 if (!data.rfzv_map[a]) continue;
964 r0 = data.rfzv_Sorted[a].begin();
965 r0e = data.rfzv_Sorted[a].end ();
966
967 if (!data.endlist) {
968 r0 = data.rMin;
969 data.endlist = true;
970 }
971
972 // Loop through trigger space points
973 //
974 for (; r0!=r0e; ++r0) {
975 float X = (*r0)->x();
976 float Y = (*r0)->y();
977 float R = (*r0)->radius();
978 if (R<m_r2minv) continue;
979 if (R>m_r2maxv) break;
980 float Z = (*r0)->z();
981 float ax = X/R;
982 float ay = Y/R;
983
984 // Bottom links production
985 //
986 int NB = m_rfzv_n[a];
987 for (int i=0; i<NB; ++i) {
988 int an = m_rfzv_i[a][i];
989 if (!data.rfzv_map[an]) continue;
990
991 r = data.rfzv_Sorted[an].begin();
992 re = data.rfzv_Sorted[an].end ();
993
994 for (; r!=re; ++r) {
995 float Rb =(*r)->radius();
996 if (Rb<m_r1minv) continue;
997 if (Rb>m_r1maxv) break;
998 float dR = R-Rb;
999 if (dR<m_drminv) break;
1000 if (dR>m_drmax) continue;
1001 float dZ = Z-(*r)->z();
1002 float Tz = dZ/dR;
1003 if (Tz<m_dzdrmin || Tz>m_dzdrmax) continue;
1004 float Zo = Z-R*Tz;
1005
1006 // Comparison with vertices Z coordinates
1007 //
1008 if (!isZCompatible(data, Zo, Rb, Tz)) continue;
1009
1010 // Momentum cut
1011 //
1012 float dx =(*r)->x()-X;
1013 float dy =(*r)->y()-Y;
1014 float x = dx*ax+dy*ay ;
1015 float y =-dx*ay+dy*ax ;
1016 float xy = x*x+y*y ; if (xy == 0.) continue;
1017 float r2 = 1./xy ;
1018 float Ut = x*r2 ;
1019 float Vt = y*r2 ;
1020 float UR = Ut*R+1. ; if (UR == 0.) continue;
1021 float A = Vt*R/UR ;
1022 float B = Vt-A*Ut ;
1023 // min pt cut
1024 if (std::abs(B*data.K) > m_ipt*std::sqrt(1.f+A*A)) continue;
1025 // max pt cut
1026 if (std::abs(B * data.K) < m_iptmax * std::sqrt(1.f + A * A)) continue;
1027 ++nseed;
1028 newSeed(data, (*r)->spacepoint, (*r0)->spacepoint,Zo);
1029 }
1030 }
1031 if (nseed < m_maxsize) continue;
1032 data.endlist=false;
1033 data.rMin = (++r0);
1034 data.fvNmin=f;
1035 data.zMin=z;
1036 return;
1037 }
1038 }
1039 }
1040 data.endlist = true;
1041}
1042
1044// Production 3 space points seeds
1046
1048{
1049 if (data.nsaz<3) return;
1050
1051 const int ZI[SizeZ] = {5,6,7,8,9,10,4,3,2,1,0};
1052 std::vector<InDet::SiSpacePointForSeed*>::iterator rt[9],rte[9],rb[9],rbe[9];
1053 int nseed = 0;
1054
1055 // Loop through all azimuthal regions
1056 //
1057 for (int f=data.fNmin; f<=m_fNmax; ++f) {
1058 // For each azimuthal region loop through all Z regions
1059 //
1060 int z = 0;
1061 if (!data.endlist) z = data.zMin;
1062
1063 for (; z<SizeZ; ++z) {
1064 int a = f*SizeZ+ZI[z];
1065 if (!data.rfz_map[a]) continue;
1066 int NB = 0, NT = 0;
1067 for (int i=0; i<m_rfz_b[a]; ++i) {
1068 int an = m_rfz_ib[a][i];
1069 if (!data.rfz_map[an]) continue;
1070 rb [NB] = data.rfz_Sorted[an].begin();
1071 rbe[NB++] = data.rfz_Sorted[an].end();
1072 }
1073 for (int i=0; i<m_rfz_t[a]; ++i) {
1074 int an = m_rfz_it[a][i];
1075 if (!data.rfz_map[an]) continue;
1076 rt [NT] = data.rfz_Sorted[an].begin();
1077 rte[NT++] = data.rfz_Sorted[an].end();
1078 }
1079 if (data.izvertex) {
1080 production3Sp(data, rb, rbe, rt, rte, NB, NT, nseed);
1081 } else {
1082 production3SpNoVertex(data, rb, rbe, rt, rte, NB, NT, nseed);
1083 }
1084 if (!data.endlist) {
1085 data.fNmin=f;
1086 data.zMin = z;
1087 return;
1088 }
1089 }
1090 }
1091 data.endlist = true;
1092}
1093
1095// Production 3 space points seeds for full scan
1097
1099(EventData& data,
1100 std::vector<InDet::SiSpacePointForSeed*>::iterator* rb ,
1101 std::vector<InDet::SiSpacePointForSeed*>::iterator* rbe,
1102 std::vector<InDet::SiSpacePointForSeed*>::iterator* rt ,
1103 std::vector<InDet::SiSpacePointForSeed*>::iterator* rte,
1104 int NB, int NT, int& nseed) const
1105{
1106 std::vector<InDet::SiSpacePointForSeed*>::iterator r0=rb[0],r;
1107 if (!data.endlist) {r0 = data.rMin; data.endlist = true;}
1108
1109 // Loop through all trigger space points
1110 //
1111 for (; r0!=rbe[0]; ++r0) {
1112 data.nOneSeeds = 0;
1113 data.mapOneSeeds.erase(data.mapOneSeeds.begin(), data.mapOneSeeds.end());
1114
1115 float R = (*r0)->radius();
1116 if (R < m_r2minv) continue;
1117 if (R > m_r2maxv) break;
1118
1119 const Trk::SpacePoint* SP0 = (*r0)->spacepoint;
1120 if (SP0->clusterList().second) break;
1121
1122 const Trk::Surface* sur0 = (*r0)->sur();
1123 float X = (*r0)->x() ;
1124 float Y = (*r0)->y() ;
1125 float Z = (*r0)->z() ;
1126 int Nb = 0 ;
1127
1128 // Bottom links production
1129 //
1130 for (int i=0; i<NB; ++i) {
1131 for (r=rb[i]; r!=rbe[i]; ++r) {
1132 float Rb =(*r)->radius();
1133 if (Rb < m_r1minv) {
1134 rb[i]=r;
1135 continue;
1136 }
1137 // if (Rb > m_r1maxv) break;
1138 float dR = R-Rb;
1139 if (dR > m_drmax) {rb[i]=r; continue;}
1140 if (dR < m_drmin_b) break;
1141 if ((*r)->sur()==sur0) continue;
1142
1143 float Tz = (Z-(*r)->z())/dR;
1144
1145 if (Tz < m_dzdrmin || Tz > m_dzdrmax) continue;
1146
1147 // Comparison with vertices Z coordinates
1148 //
1149 float Zo = Z-R*Tz;
1150 if (!isZCompatible(data, Zo, Rb, Tz)) continue;
1151 data.SP[Nb] = (*r);
1152 if (m_writeNtuple) data.SP[Nb]->setDZDR(Tz);
1153 if (++Nb==m_maxsizeSP) goto breakb;
1154 }
1155 }
1156 breakb:
1157 if (!Nb || Nb==m_maxsizeSP) continue;
1158 int Nt = Nb;
1159
1160 // Top links production
1161 //
1162 for (int i=0; i<NT; ++i) {
1163 for (r=rt[i]; r!=rte[i]; ++r) {
1164 float Rt =(*r)->radius();
1165 if (Rt < m_r3minv) {
1166 rt[i]=r;
1167 continue;
1168 }
1169 float dR = Rt-R;
1170 if (dR<m_drmin_t) {
1171 rt[i]=r;
1172 continue;
1173 }
1174 if (dR>m_drmax) break;
1175 if ( (*r)->sur()==sur0) continue;
1176
1177 float Tz = ((*r)->z()-Z)/dR;
1178
1179 if (Tz < m_dzdrmin || Tz > m_dzdrmax) continue;
1180
1181 // Comparison with vertices Z coordinates
1182 //
1183 float Zo = Z-R*Tz;
1184 if (!isZCompatible(data, Zo, R ,Tz)) continue;
1185 data.SP[Nt] = (*r);
1186 if (m_writeNtuple) data.SP[Nt]->setDZDR(Tz);
1187 if (++Nt==m_maxsizeSP) goto breakt;
1188 }
1189 }
1190
1191 breakt:
1192 if (!(Nt-Nb)) continue;
1193
1194 float covr0 = (*r0)->covr();
1195 float covz0 = (*r0)->covz();
1196
1197 float ax = X/R;
1198 float ay = Y/R;
1199
1200 for (int i=0; i<Nt; ++i) {
1201 InDet::SiSpacePointForSeed* sp = data.SP[i];
1202
1203 float dx = sp->x()-X ;
1204 float dy = sp->y()-Y ;
1205 float dz = sp->z()-Z ;
1206 float x = dx*ax+dy*ay ;
1207 float y =-dx*ay+dy*ax ;
1208 float r2 = 1.f/(x*x+y*y);
1209 float dr = std::sqrt(r2) ;
1210 float tz = dz*dr ;
1211 if (i < Nb) tz = -tz;
1212
1213 data.Tz[i] = tz ;
1214 data.Zo[i] = Z-R*tz ;
1215 data.R [i] = dr ;
1216 data.U [i] = x*r2 ;
1217 data.V [i] = y*r2 ;
1218 data.Er[i] = (covz0+sp->covz()+tz*tz*(covr0+sp->covr()))*r2;
1219 }
1220
1221 float imc = m_diver ;
1222 float ipt2 = m_ipt2 ;
1223 float ipt2max = m_iptmax * m_iptmax;
1224 float K = data.K ;
1225 float K2 = K*K ;
1226 float COF = m_COF ;
1227 float ipt2K = ipt2/K2 ;
1228 float ipt2Kmax = ipt2max/K2;
1229 float ipt2C = ipt2*COF ;
1230 float COFK = COF*K2 ;
1231 covr0 *= 2. ;
1232 covz0 *= 2. ;
1233
1234 //
1235 for (int b=0; b<Nb; ++b) {
1236 const Trk::SpacePoint* SPb = data.SP[b]->spacepoint;
1237
1238 float Zob = data.Zo[b] ;
1239 float Tzb = data.Tz[b] ;
1240 float Rb2r = data.R [b]*covr0;
1241 float Rb2z = data.R [b]*covz0;
1242 float Erb = data.Er[b] ;
1243 float Vb = data.V [b] ;
1244 float Ub = data.U [b] ;
1245 float Tzb2 = (1.f+Tzb*Tzb) ;
1246 float CSA = Tzb2*COFK ;
1247 float ICSA = Tzb2*ipt2C ;
1248 float dZ = dZVertexMin(data, Zob);
1249 float Iz = (dZ*dZ)/Tzb2 ;
1250
1251 for (int t=Nb; t<Nt; ++t) {
1252 float Ts = .5f*(Tzb+data.Tz[t]) ;
1253 float dt = Tzb-data.Tz[t] ;
1254 float dT = dt*dt-Erb-data.Er[t]-data.R[t]*(Ts*Ts*Rb2r+Rb2z);
1255 if ( dT > ICSA) continue;
1256 float dU = data.U[t]-Ub; if (dU == 0.) continue ;
1257 float A = (data.V[t]-Vb)/dU ;
1258 float S2 = 1.f+A*A ;
1259 float B = Vb-A*Ub ;
1260 float B2 = B*B ;
1261 if (B2 > ipt2K*S2 || B2 < ipt2Kmax*S2 || dT*S2 > B2*CSA) continue;
1262 float Im = std::abs((A-B*R)*R) ;
1263
1264 if ( Im > imc ) continue;
1265 Im = Im*Im+Iz;
1266 newOneSeed(data, SPb, SP0, data.SP[t]->spacepoint, Zob, Im);
1267
1268 if (m_writeNtuple) {
1269 float theta = std::atan(1.f / Ts);
1270 data.SP[t]->setEta(-std::log(std::tan(0.5f * theta)));
1271 data.SP[t]->setPt(std::sqrt(S2 / B2) / (1000.f * data.K));
1272 }
1273 }
1274 }
1275 nseed += data.mapOneSeeds.size();
1276 fillSeeds(data);
1277 if (nseed>=m_maxsize) {
1278 data.endlist=false;
1279 ++r0;
1280 data.rMin = r0;
1281 return;
1282 }
1283 }
1284}
1285
1286
1288// Production 3 space points seeds for full scan without vertex information
1290
1292(EventData& data,
1293 std::vector<InDet::SiSpacePointForSeed*>::iterator* rb ,
1294 std::vector<InDet::SiSpacePointForSeed*>::iterator* rbe,
1295 std::vector<InDet::SiSpacePointForSeed*>::iterator* rt ,
1296 std::vector<InDet::SiSpacePointForSeed*>::iterator* rte,
1297 int NB, int NT, int& nseed) const
1298{
1299 std::vector<InDet::SiSpacePointForSeed*>::iterator r0=rb[0],r;
1300 if (!data.endlist) {
1301 r0 = data.rMin;
1302 data.endlist = true;
1303 }
1304
1305 // Loop through all trigger space points
1306 //
1307 for (; r0!=rbe[0]; ++r0) {
1308 data.nOneSeeds = 0;
1309 data.mapOneSeeds.erase(data.mapOneSeeds.begin(), data.mapOneSeeds.end());
1310
1311 float R = (*r0)->radius();
1312 if (R < m_r2minv) continue;
1313 if (R > m_r2maxv) break;
1314
1315 const Trk::SpacePoint* SP0 = (*r0)->spacepoint;
1316
1317 bool pix = true;
1318 if (SP0->clusterList().second) pix = false;
1319 const Trk::Surface* sur0 = (*r0)->sur();
1320 float X = (*r0)->x() ;
1321 float Y = (*r0)->y() ;
1322 float Z = (*r0)->z() ;
1323 int Nb = 0 ;
1324
1325 // Bottom links production
1326 //
1327 for (int i=0; i<NB; ++i) {
1328 for (r=rb[i]; r!=rbe[i]; ++r) {
1329 float Rb =(*r)->radius();
1330 if (Rb < m_r1minv) {
1331 rb[i]=r;
1332 continue;
1333 }
1334 // if (Rb > m_r1maxv) break;
1335 float dR = R-Rb;
1336 if (dR > m_drmax) {
1337 rb[i]=r;
1338 continue;
1339 }
1340 if (dR < m_drmin_b) break;
1341 if ((*r)->sur()==sur0) continue;
1342 if ( !pix && !(*r)->spacepoint->clusterList().second) continue;
1343 float Tz = (Z-(*r)->z())/dR;
1344 if (Tz < m_dzdrmin || Tz > m_dzdrmax) continue;
1345
1346 // Comparison with vertices Z coordinates
1347 //
1348 float Zo = Z-R*Tz;
1349 if (!isZCompatible(data, Zo, Rb, Tz)) continue;
1350 data.SP[Nb] = (*r);
1351 if (m_writeNtuple) data.SP[Nb]->setDZDR(Tz);
1352 if (++Nb==m_maxsizeSP) goto breakb;
1353 }
1354 }
1355 breakb:
1356 if (!Nb || Nb==m_maxsizeSP) continue;
1357 int Nt = Nb;
1358
1359 // Top links production
1360 //
1361 for (int i=0; i<NT; ++i) {
1362 for (r=rt[i]; r!=rte[i]; ++r) {
1363 float Rt =(*r)->radius();
1364 if (Rt < m_r3minv) {
1365 rt[i]=r;
1366 continue;
1367 }
1368 float dR = Rt-R;
1369 if (dR<m_drmin_t) {
1370 rt[i]=r;
1371 continue;
1372 }
1373 if (dR > m_drmax) break;
1374 if ((*r)->sur()==sur0) continue;
1375 float Tz = ((*r)->z()-Z)/dR;
1376 if (Tz < m_dzdrmin || Tz > m_dzdrmax) continue;
1377
1378 // Comparison with vertices Z coordinates
1379 //
1380 float Zo = Z-R*Tz;
1381 if (!isZCompatible(data, Zo, R, Tz)) continue;
1382 data.SP[Nt] = (*r);
1383 if (m_writeNtuple) data.SP[Nt]->setDZDR(Tz);
1384 if (++Nt==m_maxsizeSP) goto breakt;
1385 }
1386 }
1387
1388 breakt:
1389 if (!(Nt-Nb)) continue;
1390
1391 float covr0 = (*r0)->covr();
1392 float covz0 = (*r0)->covz();
1393
1394 float ax = X/R;
1395 float ay = Y/R;
1396
1397 for (int i=0; i<Nt; ++i) {
1398 InDet::SiSpacePointForSeed* sp = data.SP[i];
1399
1400 float dx = sp->x()-X ;
1401 float dy = sp->y()-Y ;
1402 float dz = sp->z()-Z ;
1403 float x = dx*ax+dy*ay ;
1404 float y =-dx*ay+dy*ax ;
1405 float r2 = 1.f/(x*x+y*y);
1406 float dr = std::sqrt(r2) ;
1407 float tz = dz*dr ;
1408 if (i < Nb) tz = -tz;
1409
1410 data.Tz[i] = tz ;
1411 data.Zo[i] = Z-R*tz ;
1412 data.R [i] = dr ;
1413 data.U [i] = x*r2 ;
1414 data.V [i] = y*r2 ;
1415 data.Er[i] = (covz0+sp->covz()+tz*tz*(covr0+sp->covr()))*r2;
1416 }
1417
1418 float imc = m_diver ;
1419 float imcs = m_diverpps;
1420 float ipt2 = m_ipt2 ;
1421 float ipt2max = m_iptmax * m_iptmax;
1422 float K = data.K ;
1423 float K2 = K*K ;
1424 float COF = m_COF ;
1425 float ipt2K = ipt2/K2 ;
1426 float ipt2Kmax = ipt2max/K2;
1427 float ipt2C = ipt2*COF ;
1428 float COFK = COF*K2 ;
1429 covr0 *= 2. ;
1430 covz0 *= 2. ;
1431
1432 // Three space points comparison
1433 //
1434 for (int b=0; b<Nb; ++b) {
1435 const Trk::SpacePoint* SPb = data.SP[b]->spacepoint;
1436
1437 float Zob = data.Zo[b] ;
1438 float Tzb = data.Tz[b] ;
1439 float Rb2r = data.R [b]*covr0;
1440 float Rb2z = data.R [b]*covz0;
1441 float Erb = data.Er[b] ;
1442 float Vb = data.V [b] ;
1443 float Ub = data.U [b] ;
1444 float Tzb2 = (1.f+Tzb*Tzb) ;
1445 float CSA = Tzb2*COFK ;
1446 float ICSA = Tzb2*ipt2C ;
1447
1448 for (int t=Nb; t<Nt; ++t) {
1449 float Ts = .5f*(Tzb+data.Tz[t]) ;
1450 float dt = Tzb-data.Tz[t] ;
1451 float dT = dt*dt-Erb-data.Er[t]-data.R[t]*(Ts*Ts*Rb2r+Rb2z);
1452 if ( dT > ICSA) continue;
1453 float dU = data.U[t]-Ub;
1454 if (dU == 0.) continue;
1455 float A = (data.V[t]-Vb)/dU ;
1456 float S2 = 1.f+A*A ;
1457 float B = Vb-A*Ub ;
1458 float B2 = B*B ;
1459 if (B2 > ipt2K*S2 || B2 < ipt2Kmax*S2 || dT*S2 > B2*CSA) continue;
1460 float Im = std::abs((A-B*R)*R) ;
1461
1462 if (pix) {
1463 if ( Im > imc ) continue;
1464 if (data.SP[t]->spacepoint->clusterList().second && Im > imcs) continue;
1465 } else if (Im > m_diversss) {
1466 continue;
1467 }
1468 newOneSeed(data, SPb, SP0, data.SP[t]->spacepoint, Zob, Im);
1469
1470 if (m_writeNtuple) {
1471 float theta = std::atan(1.f / Ts);
1472 data.SP[t]->setEta(-std::log(std::tan(0.5f * theta)));
1473 data.SP[t]->setPt(std::sqrt(S2 / B2) / (1000.f * data.K));
1474 }
1475 }
1476 }
1477 nseed += data.mapOneSeeds.size();
1478 fillSeeds(data);
1479 if (nseed>=m_maxsize) {
1480 data.endlist=false;
1481 ++r0;
1482 data.rMin = r0;
1483 return;
1484 }
1485 }
1486}
1487
1489// New 3 space points seeds from one space points
1491
1493(EventData& data,
1494 const Trk::SpacePoint*& p1,const Trk::SpacePoint*& p2,
1495 const Trk::SpacePoint*& p3,const float& z,const float& q) const
1496{
1497 if (data.nOneSeeds < m_maxOneSize) {
1498
1499 data.OneSeeds[data.nOneSeeds].erase();
1500 data.OneSeeds[data.nOneSeeds].add(p1);
1501 data.OneSeeds[data.nOneSeeds].add(p2);
1502 data.OneSeeds[data.nOneSeeds].add(p3);
1503 data.OneSeeds[data.nOneSeeds].setZVertex(static_cast<double>(z));
1504 data.mapOneSeeds.insert(std::make_pair(q, &(data.OneSeeds[data.nOneSeeds])));
1505 ++data.nOneSeeds;
1506 } else {
1507 std::multimap<float,InDet::SiSpacePointsSeed*>::reverse_iterator
1508 l = data.mapOneSeeds.rbegin();
1509 if ((*l).first <= q) return;
1510
1511 InDet::SiSpacePointsSeed* s = (*l).second;
1512 s->erase();
1513 s->add(p1);
1514 s->add(p2);
1515 s->add(p3);
1516 s->setZVertex(static_cast<double>(z));
1517 std::multimap<float,InDet::SiSpacePointsSeed*>::iterator
1518 i = data.mapOneSeeds.insert(std::make_pair(q,s));
1519
1520 for (++i; i!=data.mapOneSeeds.end(); ++i) {
1521 if ((*i).second==s) {
1522 data.mapOneSeeds.erase(i);
1523 return;
1524 }
1525 }
1526 }
1527}
1528
1530{
1531 if (not data.initialized) initializeEventData(data);
1532
1533 if (data.i_seed==data.i_seede) {
1534 findNext(data);
1535 //cppcheck-suppress identicalInnerCondition
1536 if (data.i_seed==data.i_seede) return nullptr;
1537 }
1538 return &(*data.i_seed++);
1539}
1540
1542(EventData& data, float& Zv, float& R, float& T) const
1543{
1544 if (m_useVertexPosition) {
1545 if (Zv < data.zCollisionMinimum || Zv > data.zCollisionMaximum) return false;
1546 }
1547 else {
1548 if (Zv < m_zmin || Zv > m_zmax) return false;
1549 }
1550 if (!data.izvertex) return true;
1551
1552 float dZmin = std::numeric_limits<float>::max();
1553 for (const float& v: data.l_vertex) {
1554 float dZ = std::abs(v-Zv);
1555 if (dZ<dZmin) dZmin=dZ;
1556 }
1557 return dZmin < (m_dzver+m_dzdrver*R)*sqrt(1.+T*T);
1558}
1559
1561{
1562 float dZm = std::numeric_limits<float>::max();
1563 for (const float& v: data.l_vertex) {
1564 float dZ = std::abs(v-Z);
1565 if (dZ<dZm) dZm = dZ;
1566 }
1567 return dZm;
1568}
1569
1571// New space point for seeds
1573
1575(EventData& data, const Trk::SpacePoint*const& sp)
1576{
1577 InDet::SiSpacePointForSeed* sps = nullptr;
1578
1579 std::array<float, 3> r{0, 0, 0};
1580 convertToBeamFrameWork(data, sp, r);
1581
1582 if (data.i_spforseed!=data.l_spforseed.end()) {
1583 sps = &(*data.i_spforseed++);
1584 sps->set(sp,r);
1585 } else {
1586 data.l_spforseed.emplace_back(sp, r);
1587 sps = &(data.l_spforseed.back());
1588 data.i_spforseed = data.l_spforseed.end();
1589 }
1590
1591 return sps;
1592}
1593
1595// New 2 space points seeds
1597
1599(EventData& data,
1600 const Trk::SpacePoint*& p1, const Trk::SpacePoint*& p2,
1601 const float& z)
1602{
1603 if (data.i_seede!=data.l_seeds.end()) {
1604 InDet::SiSpacePointsSeed* s = &(*data.i_seede++);
1605 s->erase();
1606 s->add(p1);
1607 s->add(p2);
1608 s->setZVertex(static_cast<double>(z));
1609 } else {
1610 data.l_seeds.emplace_back(p1, p2, z);
1611 data.i_seede = data.l_seeds.end();
1612 }
1613}
1614
1616// New 3 space points seeds
1618
1620(EventData& data,
1621 const Trk::SpacePoint*& p1, const Trk::SpacePoint*& p2,
1622 const Trk::SpacePoint*& p3, const float& z)
1623{
1624 if (data.i_seede!=data.l_seeds.end()) {
1625 InDet::SiSpacePointsSeed* s = &(*data.i_seede++);
1626 s->erase();
1627 s->add(p1);
1628 s->add(p2);
1629 s->add(p3);
1630 s->setZVertex(static_cast<double>(z));
1631 } else {
1632 data.l_seeds.emplace_back(p1, p2, p3, z);
1633 data.i_seede = data.l_seeds.end();
1634 }
1635}
1636
1638// Fill seeds
1640
1642{
1643 std::multimap<float, InDet::SiSpacePointsSeed*>::iterator
1644 l = data.mapOneSeeds.begin(),
1645 le = data.mapOneSeeds.end ();
1646 for (; l!=le; ++l) {
1647 if (data.i_seede!=data.l_seeds.end()) {
1648 InDet::SiSpacePointsSeed* s = &(*data.i_seede++);
1649 *s = *(*l).second;
1650 } else {
1651 data.l_seeds.emplace_back(*(*l).second);
1652 data.i_seede = data.l_seeds.end();
1653 }
1654 }
1655}
1656
1658 data.initialize(EventData::ToolType::HeavyIon,
1661 0, // maxsize not used
1662 m_r_size,
1663 0, // sizeRF not used
1664 SizeRFZ,
1665 SizeRFZV,
1666 false); // checkEta not used
1667}
1668
1670 const Trk::Track* track,
1671 int seedType,
1672 long eventNumber) const
1673{
1674 if (not m_writeNtuple) return;
1675
1676 std::lock_guard<std::mutex> lock(m_mutex);
1677
1678 if (track != nullptr) {
1679 m_trackPt = track->trackParameters()->front()->pT() / 1000.f;
1680 m_trackEta = std::abs(track->trackParameters()->front()->eta());
1681 } else {
1682 m_trackPt = -1.;
1683 m_trackEta = -1.;
1684 }
1685
1686 const std::vector<const Trk::SpacePoint*>& sps = seed->spacePoints();
1687
1688 m_d0 = seed->d0();
1689 m_z0 = seed->zVertex();
1690 m_eta = sps[0]->globalPosition().eta();
1691 m_x1 = sps[0]->globalPosition().x();
1692 m_x2 = sps[1]->globalPosition().x();
1693 m_x3 = sps[2]->globalPosition().x();
1694 m_y1 = sps[0]->globalPosition().y();
1695 m_y2 = sps[1]->globalPosition().y();
1696 m_y3 = sps[2]->globalPosition().y();
1697 m_z1 = sps[0]->globalPosition().z();
1698 m_z2 = sps[1]->globalPosition().z();
1699 m_z3 = sps[2]->globalPosition().z();
1700 m_r1 = sps[0]->globalPosition().perp();
1701 m_r2 = sps[1]->globalPosition().perp();
1702 m_r3 = sps[2]->globalPosition().perp();
1703 m_type = seedType;
1704 m_dzdr_b = ( sps[1]->globalPosition().z() - sps[0]->globalPosition().z() )/( sps[1]->globalPosition().perp() - sps[0]->globalPosition().perp());
1705 m_dzdr_t = ( sps[2]->globalPosition().z() - sps[1]->globalPosition().z()) / (sps[2]->globalPosition().perp() - sps[1]->globalPosition().perp());
1706 m_dr_b = sps[1]->globalPosition().perp() - sps[0]->globalPosition().perp();
1707 m_dr_t = sps[2]->globalPosition().perp() - sps[1]->globalPosition().perp();
1708 m_pt = seed->pt();
1709 m_givesTrack = !(track == nullptr);
1710 m_eventNumber = eventNumber;
1711
1712 TTree* outputTree ATLAS_THREAD_SAFE = m_outputTree;
1713 outputTree->Fill();
1714}
1715
const std::regex re(r_e)
#define M_PI
Scalar perp() const
perp method - perpendicular length
Scalar theta() const
theta method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
static Double_t sp
static Double_t a
static Double_t sc
#define F(x, y, z)
Definition MD5.cxx:112
#define X(x)
Definition SiHitPlots.h:102
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 >)
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 newRegion(const EventContext &ctx, EventData &data, const std::vector< IdentifierHash > &vPixel, const std::vector< IdentifierHash > &vSCT) const override
void newOneSeed(EventData &data, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const float &, const float &) const
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_prdToTrackMap
static MsgStream & dumpEvent(EventData &data, MsgStream &out)
bool isUsed(const Trk::SpacePoint *sp, const Trk::PRDtoTrackMap &prd_to_track_map) const
bool newVertices(EventData &data, const std::list< Trk::Vertex > &) const
bool isZCompatible(EventData &data, float &, float &, float &) const
void buildBeamFrameWork(const EventContext &ctx, EventData &data) const
virtual void newEvent(const EventContext &ctx, EventData &data, int iteration) const override
SG::ReadHandleKey< SpacePointOverlapCollection > m_spacepointsOverlap
virtual const SiSpacePointsSeed * next(const EventContext &ctx, EventData &data) const override
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 &, std::array< float, 3 > &)
static void newSeed(EventData &data, const Trk::SpacePoint *&, const Trk::SpacePoint *&, const float &)
static float dZVertexMin(EventData &data, float &)
MsgStream & dumpConditions(EventData &data, MsgStream &out) const
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
SG::ReadHandleKey< SpacePointContainer > m_spacepointsSCT
virtual void findVSp(const EventContext &ctx, EventData &data, const std::list< Trk::Vertex > &lv) const override
SG::ReadHandleKey< SpacePointContainer > m_spacepointsPixel
void production3SpNoVertex(EventData &data, std::vector< InDet::SiSpacePointForSeed * >::iterator *, std::vector< InDet::SiSpacePointForSeed * >::iterator *, std::vector< InDet::SiSpacePointForSeed * >::iterator *, std::vector< InDet::SiSpacePointForSeed * >::iterator *, int, int, int &) const
static SiSpacePointForSeed * newSpacePoint(EventData &data, const Trk::SpacePoint *const &)
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCondObjInputKey
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
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.
Definition Surface.h:79
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:926
Eigen::Matrix< double, 3, 1 > Vector3D
-event-from-file
hold the test vectors and ease the comparison
MsgStream & msg
Definition testRead.cxx:32