ATLAS Offline Software
Loading...
Searching...
No Matches
TrackRoiSelector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
12
14#include "TrackRoiSelector.h"
15#include "TrackView.h"
16
18#include <cmath> // std::fabs
19#include <algorithm> // for std::find
20
22
26template<class T>
27bool IDTPM2::TrackRoiSelector::accept( const T& t, const TrigRoiDescriptor* r ) const {
28
29 if ( r==0 ) return true;
30
31 if ( t.pt()==0 ) return false; // throw runtime_error(shouldn't ever have a track with pt = 0" );
32
33 if( r->composite() ) {
34
35 for ( unsigned i=r->size() ; i-- ; ) if ( accept( t, (const TrigRoiDescriptor*)r->at(i) ) ) return true;
36
37 }
38 else {
39
40 if( r->isFullscan() ) return true;
41
42 // std::cout << "r->
43
47 bool contained_phi = ( r->phiMinus()<r->phiPlus() ) ?
48 ( t.phi()>r->phiMinus() && t.phi()<r->phiPlus() ) :
49 ( t.phi()>r->phiMinus() || t.phi()<r->phiPlus() );
50
52 bool contained_zed = ( t.z0()>r->zedMinus() && t.z0()<r->zedPlus() );
53
56 bool contained_eta = ( t.eta()<r->etaPlus() && t.eta()>r->etaMinus() );
57
60
61#if 0
65 // RoiDescriptor so that computes and stores it's exit points as standard
66
67 exit_point ex;
68 exit_point explus;
69 exit_point exminus;
70
71 TIDARoiDescriptor::exitpoint( t.z0(), t.eta(), ex.z, ex.r );
72
73 TIDARoiDescriptor::exitpoint( r->zedPlus(), r->etaPlus(), explus.z, explus.r );
74 TIDARoiDescriptor::exitpoint( r->zedMinus(), r->etaMinus(), exminus.z, exminus.r );
75
76#else
77
84 exit_point ex = getExitPoint( t.z0(), t.eta() );
85 exit_point explus = getExitPoint( r->zedPlus(), r->etaPlus() );
86 exit_point exminus = getExitPoint( r->zedMinus(), r->etaMinus() );
87#endif
88
89 float cross0 = ex.z*exminus.r - ex.r*exminus.z;
90 float cross1 = ex.z*explus.r - ex.r*explus.z;
91
92 contained_eta = ( cross0>0 && cross1<0 ) ? true : false;
93
96 std::optional<double> newphi = getOuterPhi( t.pt(), t.phi(), ex.r );
97
98 if( !newphi ) return false;
99
100 if( r->phiMinus() < r->phiPlus() ) contained_phi &= ( newphi > r->phiMinus() && newphi < r->phiPlus() );
101 else contained_phi &= ( newphi > r->phiMinus() || newphi < r->phiPlus() );
102
103 if( contained_eta && contained_phi && contained_zed ) return true;
104 }
105
106 return false;
107}
108
109
110
112template bool IDTPM2::TrackRoiSelector::accept( const TrackView& t, const TrigRoiDescriptor* r ) const;
113
114
118std::optional<double> IDTPM2::TrackRoiSelector::getOuterPhi( float pt, float phi, float r ) const {
119
122
123
125 double mqR = 10 * pt / ( 2.99792458 * 2 ); // 2.998=speed of light, 2=Atlas B field
126 double ratio = 0.5 * r / mqR;
127 double newphi = phi;
128
130 if ( std::fabs(ratio)>1 ) return std::nullopt;
131
133 newphi -= std::asin( ratio );
134
137 while( newphi < -M_PI ) newphi += 2 * M_PI;
138 while( newphi > M_PI ) newphi -= 2 * M_PI;
139
140 return newphi;
141}
142
143
146
147#if 1
152
153 exit_point exitPoint;
154
155 double rexit = 0;
156 double zexit = 0;
157 const double maxRadius = 1000.;
158 const double maxZed = 2700.;
159
160 if ( teta < 0 ) zexit = -maxZed;
161 else if ( teta > 0 ) zexit = maxZed;
162 else {
163 exitPoint.z = tz0;
164 exitPoint.r = maxRadius;
165 return exitPoint;
166 }
167
168 double tantheta = std::tan( 2 * std::atan( std::exp( -teta ) ) );
169
170 rexit = ( zexit - tz0 ) * tantheta;
171
173 if ( std::fabs(rexit) > maxRadius ) {
178
179 zexit = maxRadius / tantheta + tz0;
180 rexit = maxRadius;
181 }
182
183 exitPoint.z = zexit;
184 exitPoint.r = rexit;
185
186 return exitPoint;
187}
188
189#endif
#define M_PI
Scalar phi() const
phi method
emacs: this is -*- c++ -*-
bool accept(const T &t, const TrigRoiDescriptor *r) const
geometric RoI filters - for non-trigger tracks (e.g. offline, truth, etc.)
exit_point getExitPoint(float tz0, float teta) const
why are there these "exit point functions ?
std::optional< double > getOuterPhi(float pt, float phi, float r=1000.) const
static double exitpoint(double tz0, double teta, double &zexit, double &rexit)
returns the tantheta for the limits and the r and z exit points from the ID volume
forward declaration required for function prototype
Definition TrackView.h:43
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
int r
Definition globals.cxx:22