14 #include "GaudiKernel/MsgStream.h"
15 #include "GaudiKernel/ServiceHandle.h"
16 #include "CLHEP/Vector/ThreeVector.h"
44 (
const std::string&
t,
const std::string&
n,
const IInterface*
p)
47 declareInterface<ITRT_SeededSpacePointFinder>(
this);
71 return StatusCode::FAILURE;
102 std::unique_ptr<InDet::ITRT_SeededSpacePointFinder::IEventData>
105 std::unique_ptr<InDet::TRT_SeededSpacePointFinder_ATL::EventData> event_data_p = std::make_unique<InDet::TRT_SeededSpacePointFinder_ATL::EventData>();
111 std::vector< std::vector<const Trk::SpacePoint*> > r_Sorted;
112 r_Sorted.resize(event_data_p->
m_r_size);
118 if (spacepointsPix.
isValid()) {
122 for(; spc != spce; ++spc) {
126 for(; sp != spe; ++sp) {
128 double r = (*sp)->r();
if(r<0. || r>=
m_r_rmax)
continue;
131 r_Sorted[
ir].push_back(sps);
134 ++event_data_p->
m_ns;
143 if (!prd_to_track_map.
isValid()) {
144 ATH_MSG_ERROR(
"Failed to read PRD to track association map.");
150 if (spacepointsSCT.
isValid()) {
156 for(; spc != spce; ++spc) {
160 for(; sp != spe; ++sp) {
162 if(prd_to_track_map.
cptr()){
163 bool u1=
false;
bool u2=
false;
166 if(u1 || u2){
continue;}
169 double r = (*sp)->r();
if(r<r_rmin || r>=
m_r_rmax)
continue;
172 r_Sorted[
ir].push_back(sps); ++event_data_p->
m_r_map[
ir];
174 ++event_data_p->
m_ns;
182 if (spacepointsOverlap.
isValid()) {
186 for (; sp!=spe; ++sp) {
188 if(prd_to_track_map.
cptr()){
189 bool u1=
false;
bool u2=
false;
192 if(u1 || u2){
continue;}
195 double r = (*sp)->r();
if(r<0. || r>=
m_r_rmax)
continue;
198 r_Sorted[
ir].push_back(sps); ++event_data_p->
m_r_map[
ir];
200 ++event_data_p->
m_ns;
205 return std::unique_ptr<InDet::ITRT_SeededSpacePointFinder::IEventData>(event_data_p.release());
213 (
const std::vector<IdentifierHash>& vPixel,
const std::vector<IdentifierHash>& vSCT)
const
215 std::unique_ptr<InDet::TRT_SeededSpacePointFinder_ATL::EventData> event_data_p = std::make_unique<InDet::TRT_SeededSpacePointFinder_ATL::EventData>();
218 std::vector< std::vector<const Trk::SpacePoint*> > r_Sorted;
219 r_Sorted.resize(event_data_p->
m_r_size);
227 if (spacepointsPix.
isValid()) {
228 std::vector<IdentifierHash>::const_iterator
l = vPixel.begin(), le = vPixel.end();
235 if(
w==
nullptr)
continue;
238 for(; sp != spe; ++sp) {
240 double r = (*sp)->r();
if(r<0. || r>=
m_r_rmax)
continue;
243 r_Sorted[
ir].push_back(sps); ++event_data_p->
m_r_map[
ir];
245 ++event_data_p->
m_ns;
256 if (spacepointsSCT.
isValid()) {
261 if (!prd_to_track_map.
isValid()) {
262 ATH_MSG_ERROR(
"Failed to read PRD to track association map.");
265 std::vector<IdentifierHash>::const_iterator
l = vSCT.begin(), le = vSCT.end();
273 if(
w==
nullptr)
continue;
276 for(; sp != spe; ++sp) {
278 if(prd_to_track_map.
cptr()){
279 bool u1=
false;
bool u2=
false;
282 if(u1 || u2){
continue;}
285 double r = (*sp)->r();
if(r<r_rmin || r>=
m_r_rmax)
continue;
288 r_Sorted[
ir].push_back(sps); ++event_data_p->
m_r_map[
ir];
290 ++event_data_p->
m_ns;
297 return std::unique_ptr<InDet::ITRT_SeededSpacePointFinder::IEventData>(event_data_p.release());
305 std::list<std::pair<const Trk::SpacePoint*, const Trk::SpacePoint*> >
315 std::list<std::pair<const Trk::SpacePoint*,const Trk::SpacePoint*> > outputListBuffer;
320 F=atan2(GPy,GPx);
if(
F<0.)
F+=
pi2;
336 if(outputListBuffer.size()>10000.) outputListBuffer.clear();
338 return outputListBuffer;
349 std::string s1;
for(
int i=0;
i<
n; ++
i) s1.append(
" "); s1.append(
"|");
351 std::string
s3;
for(
int i=0;
i<
n; ++
i)
s3.append(
" ");
s3.append(
"|");
353 std::string
s4;
for(
int i=0;
i<
n; ++
i)
s4.append(
" ");
s4.append(
"|");
355 std::string fieldmode[9] ={
"NoField" ,
"ConstantField",
"SolenoidalField",
356 "ToroidalField" ,
"Grid3DField" ,
"RealisticField" ,
357 "UndefinedField",
"AthenaField" ,
"?????" };
360 if(mode<0 || mode>8 )
mode = 8;
362 n = 62-fieldmode[
mode].size();
363 std::string s5;
for(
int i=0;
i<
n; ++
i) s5.append(
" "); s5.append(
"|");
365 out<<
"|---------------------------------------------------------------------|"
373 out<<
"| Magnetic field mode | "<<fieldmode[
mode]<<s5
375 out<<
"| pTmin (mev) | "
376 <<std::setw(12)<<std::setprecision(5)<<
m_ptmin
378 out<<
"| max radius SP | "
379 <<std::setw(12)<<std::setprecision(5)<<
m_r_rmax
381 out<<
"| radius step | "
382 <<std::setw(12)<<std::setprecision(5)<<
m_r_rstep
384 out<<
"| min radius second SP(3) | "
385 <<std::setw(12)<<std::setprecision(5)<<
m_r2min
387 out<<
"| min radius first SP(3) | "
388 <<std::setw(12)<<std::setprecision(5)<<
m_r12min
390 out<<
"| max radius first SP(3) | "
391 <<std::setw(12)<<std::setprecision(4)<<
m_r1max
393 out<<
"| min seeds dZ/dR | "
394 <<std::setw(12)<<std::setprecision(5)<<
m_dzdrmin
396 out<<
"| max seeds dZ/dR | "
397 <<std::setw(12)<<std::setprecision(5)<<
m_dzdrmax
399 out<<
"| momentum chi2 cut | "
400 <<std::setw(12)<<std::setprecision(5)<<
m_xiC
402 out<<
"| polar angle chi2 cut | "
403 <<std::setw(12)<<std::setprecision(5)<<
m_xiTC
405 out<<
"| azimuthal angle chi2 cut | "
406 <<std::setw(12)<<std::setprecision(5)<<
m_xiFC
408 out<<
"|---------------------------------------------------------------------|"
420 explicit StreamState(std::ostream&
out)
421 : m_out(
out), m_prec(
out.precision())
427 m_out.precision(m_prec);
432 std::streamsize m_prec;
439 out<<
"|---------------------------------------------------------------------|"
442 <<std::setw(12)<<event_data.
m_ns
444 out<<
"|---------------------------------------------------------------------|"
449 out<<
"|-------------|--------|-------|-------|-------|-------|-------|";
450 out<<
"-------|-------|-------|-------|-------|-------|"
453 out<<
"| Azimuthal | n | z[ 0] | z[ 1] | z[ 2] | z[ 3] | z[4] |";
454 out<<
" z[ 5] | z[ 6] | z[ 7] | z[ 8] | z[ 9] | z[10] |"
456 out<<
"|-------------|--------|-------|-------|-------|-------|-------|";
457 out<<
"-------|-------|-------|-------|-------|-------|"
466 <<std::setw(10)<<std::setprecision(4)<<sF1*
double(
f)<<
" | "
467 <<std::setw(6)<<event_data.
m_rf_map[
f]<<
" |";
470 out<<
"|-------------|--------|-------|-------|-------|-------|-------|";
471 out<<
"-------|-------|-------|-------|-------|-------|"
511 const int NFmax = 530 ;
526 assert(
static_cast<size_t>(event_data.
m_r_size) == r_Sorted.size());
530 if(!event_data.
m_r_map[
i])
continue;
535 double F = space_point->phi();
if(
F<0.)
F+=
pi2;
541 int isBRL = 1000;
int isLYR = 1000;
int DD = 1000;
543 geoInfo(space_point,isBRL,isLYR);
547 DD = ((isBRL+3) << 4) + (isLYR & 15);
566 for(
int i=0;
i!=m_nrf; ++
i) {
567 int n = m_rf_index[
i]; m_rf_map[
n] = 0;
568 m_rf_Sorted[
n].erase(m_rf_Sorted[
n].
begin(),m_rf_Sorted[
n].
end());
589 double rquadrant = rotations*4.0;
590 long quadrant = (long)rquadrant & 3;
592 if ((quadrant & 1) != 0) {
599 quadrant -= ((quadrant & 2) << 1);
600 return quadrant + twist;
612 double *
min,
double *
max) {
629 long asign_x = (long)(
x < 0.0);
630 long asign_y = (long)(
y < 0.0);
631 long quadrant = -(asign_y << 1) + (asign_y ^ asign_x);
635 double numerator = ((quadrant & 1) != 0) ?
x2 :
y2;
643 std::list<std::pair<const Trk::SpacePoint*,const Trk::SpacePoint*> > &outputListBuffer,
654 double sPhi = (*vCM)(2,2) ;
655 double sTheta = (*vCM)(3,3);
656 double sp = (*vCM)(4,4) ;
658 double ipdelta = sqrt(
m_xiC*sp);
661 tmp_invar_bypass.
invp_min = pTS[4] - ipdelta;
662 tmp_invar_bypass.invp_max = pTS[4] + ipdelta;
664 tmp_invar_bypass.invp_min2 = tmp_invar_bypass.invp_min*tmp_invar_bypass.invp_min;
665 tmp_invar_bypass.invp_max2 = tmp_invar_bypass.invp_max*tmp_invar_bypass.invp_max;
667 double theta_center = pTS[3];
668 double theta_delta = sqrt(
m_xiTC*sTheta);
670 double phi_center = pTS[2];
671 double phi_delta = sqrt(
m_xiFC*sPhi);
674 &(tmp_invar_bypass.min_theta), &(tmp_invar_bypass.max_theta));
676 &(tmp_invar_bypass.min_phi), &(tmp_invar_bypass.max_phi));
684 double H[3];
double gP[3] = {x0,y0,
z0};
689 if (fieldCondObj ==
nullptr) {
694 fieldCondObj->getInitializedCache (fieldCache);
702 std::list<std::pair<const Trk::SpacePoint*,int> >
::iterator r0,r0e,
r,
re,
rb;
708 int fmin=phi;
int fmax=phi;
709 if(
m_search){fmin = phi-1; fmax = phi+1;}
710 for(
int f=fmin;
f<=fmax; ++
f) {
719 for(; r0!=r0e; ++r0){
720 if((((*r0).first)->r() >
m_r1max) ||
721 (((*r0).first)->r() <
m_r2min)) {
730 int fmin=phi;
int fmax=phi;
731 for(
int f=fmin;
f<=fmax; ++
f) {
740 for(; r0!=r0e; ++r0){
741 if((((*r0).first)->r()>
m_r1max) || (((*r0).first)->r()<
m_r2min)) {
760 std::vector<bypass_struct> tmp_prod_bypass;
761 std::vector<const Trk::SpacePoint *> vrp;
762 std::vector<double> rk;
763 std::vector<long> geo_info;
764 std::vector<double> zSP;
765 tmp_prod_bypass.reserve(spcount);
766 vrp.reserve(spcount);
768 geo_info.reserve(spcount);
769 zSP.reserve(spcount);
772 for (;
r !=
re; ++
r) {
775 geo_info.push_back((*r).second);
777 rk.push_back(vrpi->
r());
783 double Z = zSPi -
z0;
785 double RR =
X*
X +
Y*
Y;
792 tmp_prod_bypass.emplace_back();
793 tmp_prod_bypass.back().X =
X;
794 tmp_prod_bypass.back().Y =
Y;
795 tmp_prod_bypass.back().Z = Z;
797 tmp_prod_bypass.back().R = R;
798 tmp_prod_bypass.back().invR = invR;
800 tmp_prod_bypass.back().a =
a;
801 tmp_prod_bypass.back().b =
b;
809 for (
long i = 0;
i < (long)spcount;
i++) {
812 for (
long j =
i + 1; j < (long)spcount; j++) {
815 outputListBuffer.emplace_back(
up, SpToPair);
818 outputListBuffer.emplace_back(
up,
up);
823 for (
long i = 0;
i < (long)spcount;
i++) {
831 long geoi = geo_info[
i];
832 int isBU = (geoi >> 4)-3;
833 int eleU = geoi & 15;
835 for (
long j =
i + 1; j < (long)spcount; j++) {
839 long geoj = geo_info[j];
840 int isBB = (geoj >> 4)-3;
841 int eleB = geoj & 15;
851 int Bd = (isBU - isBB) | (isBB - isBU);
852 int Ed = (eleB - eleU);
853 int BUzero = (isBU | -isBU);
854 if (((BUzero | ~Bd) & (Bd | Ed) & (((
unsigned)(-1) >> 1) + 1))
864 if (dZ < dz_min || dZ > dz_max) {
868 if(!
cutTPb(tmp_invar_bypass, tmp_prod_bypass,
i, j,
H[2])) {
873 outputListBuffer.emplace_back(
up, SpToPair);
876 outputListBuffer.emplace_back(
up,
up);
892 const std::vector<bypass_struct> &tmp_prod_bypass,
893 long bSP1,
long bSP2,
double H)
const
896 double inv_r2 = tmp_prod_bypass[bSP2].invR;
897 double inv_r1 = tmp_prod_bypass[bSP1].invR;
898 double r1 = tmp_prod_bypass[bSP1].R;
900 double inv_rr2 = inv_r2*inv_r2;
901 double x2 = tmp_prod_bypass[bSP2].X;
902 double y2 = tmp_prod_bypass[bSP2].Y;
903 double a1 = tmp_prod_bypass[bSP1].a;
904 double b1 = tmp_prod_bypass[bSP1].b;
906 double u2 = (a1*
x2 + b1*
y2)*inv_rr2;
907 double v2 = (a1*
y2 - b1*
x2)*inv_rr2;
909 double A =
v2/(u2 - inv_r1);
910 double B = 2.0*(
v2 -
A*u2);
911 double CC = B*B/(1.0 +
A*
A);
912 double rcrc =
CC*r1*r1;
913 double z1 = tmp_prod_bypass[bSP1].Z;
914 double T = -z1/(r1*(1.0 + 0.04*rcrc));
916 if(
H==0.)
return false;
918 double invpSignature = B*
H;
920 double invP2 =
CC/(0.03*0.03*
H*
H*(1.0 + T*T));
926 double invp_min = tmp_invar_bypass.
invp_min;
927 double invp_max = tmp_invar_bypass.
invp_max;
929 double invp_min2 = tmp_invar_bypass.
invp_min2;
930 double invp_max2 = tmp_invar_bypass.
invp_max2;
933 if (invpSignature < 0 || invP2 < invp_min2) {
938 if (invpSignature < 0 && invP2 > invp_min2) {
943 if (invpSignature >= 0 && invP2 > invp_max2) {
948 if (invpSignature >= 0 || invP2 < invp_max2) {
956 double tmin = tmp_invar_bypass.
min_theta;
957 double tmax = tmp_invar_bypass.
max_theta;
960 #ifndef ANGLE_DISCO_COMPAT
962 if (theta_rating >= 0) {
970 if (tmin + tmax <= 0) {
981 if (theta_rating < tmin || theta_rating > tmax) {
985 double phi_rating =
rotrating(-(b1 + a1*
A), -(a1 - b1*
A));
986 double pmin = tmp_invar_bypass.
min_phi;
987 double pmax = tmp_invar_bypass.
max_phi;
990 #ifndef ANGLE_DISCO_COMPAT
992 if (phi_rating >= 0) {
1000 if (pmin + pmax <= 0) {
1011 return phi_rating >= pmin && phi_rating <= pmax;
1032 id=
c1->detectorElement()->identify();