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)
46 m_fieldmode(
"MapSolenoid"),
66 declareInterface<ITRT_SeededSpacePointFinder>(
this);
100 return StatusCode::FAILURE;
131 std::unique_ptr<InDet::ITRT_SeededSpacePointFinder::IEventData>
134 std::unique_ptr<InDet::TRT_SeededSpacePointFinder_ATL::EventData> event_data_p = std::make_unique<InDet::TRT_SeededSpacePointFinder_ATL::EventData>();
140 std::vector< std::vector<const Trk::SpacePoint*> > r_Sorted;
141 r_Sorted.resize(event_data_p->
m_r_size);
147 if (spacepointsPix.
isValid()) {
151 for(; spc != spce; ++spc) {
155 for(; sp != spe; ++sp) {
157 double r = (*sp)->r();
if(r<0. || r>=
m_r_rmax)
continue;
160 r_Sorted[
ir].push_back(sps);
163 ++event_data_p->
m_ns;
172 if (!prd_to_track_map.
isValid()) {
173 ATH_MSG_ERROR(
"Failed to read PRD to track association map.");
179 if (spacepointsSCT.
isValid()) {
185 for(; spc != spce; ++spc) {
189 for(; sp != spe; ++sp) {
191 if(prd_to_track_map.
cptr()){
192 bool u1=
false;
bool u2=
false;
195 if(u1 || u2){
continue;}
198 double r = (*sp)->r();
if(r<r_rmin || r>=
m_r_rmax)
continue;
201 r_Sorted[
ir].push_back(sps); ++event_data_p->
m_r_map[
ir];
203 ++event_data_p->
m_ns;
211 if (spacepointsOverlap.
isValid()) {
215 for (; sp!=spe; ++sp) {
217 if(prd_to_track_map.
cptr()){
218 bool u1=
false;
bool u2=
false;
221 if(u1 || u2){
continue;}
224 double r = (*sp)->r();
if(r<0. || r>=
m_r_rmax)
continue;
227 r_Sorted[
ir].push_back(sps); ++event_data_p->
m_r_map[
ir];
229 ++event_data_p->
m_ns;
234 return std::unique_ptr<InDet::ITRT_SeededSpacePointFinder::IEventData>(event_data_p.release());
242 (
const std::vector<IdentifierHash>& vPixel,
const std::vector<IdentifierHash>& vSCT)
const
244 std::unique_ptr<InDet::TRT_SeededSpacePointFinder_ATL::EventData> event_data_p = std::make_unique<InDet::TRT_SeededSpacePointFinder_ATL::EventData>();
247 std::vector< std::vector<const Trk::SpacePoint*> > r_Sorted;
248 r_Sorted.resize(event_data_p->
m_r_size);
256 if (spacepointsPix.
isValid()) {
257 std::vector<IdentifierHash>::const_iterator
l = vPixel.begin(), le = vPixel.end();
264 if(
w==
nullptr)
continue;
267 for(; sp != spe; ++sp) {
269 double r = (*sp)->r();
if(r<0. || r>=
m_r_rmax)
continue;
272 r_Sorted[
ir].push_back(sps); ++event_data_p->
m_r_map[
ir];
274 ++event_data_p->
m_ns;
285 if (spacepointsSCT.
isValid()) {
290 if (!prd_to_track_map.
isValid()) {
291 ATH_MSG_ERROR(
"Failed to read PRD to track association map.");
294 std::vector<IdentifierHash>::const_iterator
l = vSCT.begin(), le = vSCT.end();
302 if(
w==
nullptr)
continue;
305 for(; sp != spe; ++sp) {
307 if(prd_to_track_map.
cptr()){
308 bool u1=
false;
bool u2=
false;
311 if(u1 || u2){
continue;}
314 double r = (*sp)->r();
if(r<r_rmin || r>=
m_r_rmax)
continue;
317 r_Sorted[
ir].push_back(sps); ++event_data_p->
m_r_map[
ir];
319 ++event_data_p->
m_ns;
326 return std::unique_ptr<InDet::ITRT_SeededSpacePointFinder::IEventData>(event_data_p.release());
334 std::list<std::pair<const Trk::SpacePoint*, const Trk::SpacePoint*> >
344 std::list<std::pair<const Trk::SpacePoint*,const Trk::SpacePoint*> > outputListBuffer;
349 F=atan2(GPy,GPx);
if(
F<0.)
F+=
pi2;
365 if(outputListBuffer.size()>10000.) outputListBuffer.clear();
367 return outputListBuffer;
378 std::string s1;
for(
int i=0;
i<
n; ++
i) s1.append(
" "); s1.append(
"|");
380 std::string
s3;
for(
int i=0;
i<
n; ++
i)
s3.append(
" ");
s3.append(
"|");
382 std::string
s4;
for(
int i=0;
i<
n; ++
i)
s4.append(
" ");
s4.append(
"|");
384 std::string fieldmode[9] ={
"NoField" ,
"ConstantField",
"SolenoidalField",
385 "ToroidalField" ,
"Grid3DField" ,
"RealisticField" ,
386 "UndefinedField",
"AthenaField" ,
"?????" };
389 if(mode<0 || mode>8 )
mode = 8;
391 n = 62-fieldmode[
mode].size();
392 std::string s5;
for(
int i=0;
i<
n; ++
i) s5.append(
" "); s5.append(
"|");
394 out<<
"|---------------------------------------------------------------------|"
402 out<<
"| Magnetic field mode | "<<fieldmode[
mode]<<s5
404 out<<
"| pTmin (mev) | "
405 <<std::setw(12)<<std::setprecision(5)<<
m_ptmin
407 out<<
"| max radius SP | "
408 <<std::setw(12)<<std::setprecision(5)<<
m_r_rmax
410 out<<
"| radius step | "
411 <<std::setw(12)<<std::setprecision(5)<<
m_r_rstep
413 out<<
"| min radius second SP(3) | "
414 <<std::setw(12)<<std::setprecision(5)<<
m_r2min
416 out<<
"| min radius first SP(3) | "
417 <<std::setw(12)<<std::setprecision(5)<<
m_r12min
419 out<<
"| max radius first SP(3) | "
420 <<std::setw(12)<<std::setprecision(4)<<
m_r1max
422 out<<
"| min seeds dZ/dR | "
423 <<std::setw(12)<<std::setprecision(5)<<
m_dzdrmin
425 out<<
"| max seeds dZ/dR | "
426 <<std::setw(12)<<std::setprecision(5)<<
m_dzdrmax
428 out<<
"| momentum chi2 cut | "
429 <<std::setw(12)<<std::setprecision(5)<<
m_xiC
431 out<<
"| polar angle chi2 cut | "
432 <<std::setw(12)<<std::setprecision(5)<<
m_xiTC
434 out<<
"| azimuthal angle chi2 cut | "
435 <<std::setw(12)<<std::setprecision(5)<<
m_xiFC
437 out<<
"|---------------------------------------------------------------------|"
449 explicit StreamState(std::ostream&
out)
450 : m_out(
out), m_prec(
out.precision())
456 m_out.precision(m_prec);
461 std::streamsize m_prec;
468 out<<
"|---------------------------------------------------------------------|"
471 <<std::setw(12)<<event_data.
m_ns
473 out<<
"|---------------------------------------------------------------------|"
478 out<<
"|-------------|--------|-------|-------|-------|-------|-------|";
479 out<<
"-------|-------|-------|-------|-------|-------|"
482 out<<
"| Azimuthal | n | z[ 0] | z[ 1] | z[ 2] | z[ 3] | z[4] |";
483 out<<
" z[ 5] | z[ 6] | z[ 7] | z[ 8] | z[ 9] | z[10] |"
485 out<<
"|-------------|--------|-------|-------|-------|-------|-------|";
486 out<<
"-------|-------|-------|-------|-------|-------|"
495 <<std::setw(10)<<std::setprecision(4)<<sF1*
double(
f)<<
" | "
496 <<std::setw(6)<<event_data.
m_rf_map[
f]<<
" |";
499 out<<
"|-------------|--------|-------|-------|-------|-------|-------|";
500 out<<
"-------|-------|-------|-------|-------|-------|"
540 const int NFmax = 530 ;
555 assert(
static_cast<size_t>(event_data.
m_r_size) == r_Sorted.size());
559 if(!event_data.
m_r_map[
i])
continue;
564 double F = space_point->phi();
if(
F<0.)
F+=
pi2;
570 int isBRL = 1000;
int isLYR = 1000;
int DD = 1000;
572 geoInfo(space_point,isBRL,isLYR);
576 DD = ((isBRL+3) << 4) + (isLYR & 15);
595 for(
int i=0;
i!=m_nrf; ++
i) {
596 int n = m_rf_index[
i]; m_rf_map[
n] = 0;
597 m_rf_Sorted[
n].erase(m_rf_Sorted[
n].
begin(),m_rf_Sorted[
n].
end());
618 double rquadrant = rotations*4.0;
619 long quadrant = (long)rquadrant & 3;
621 if ((quadrant & 1) != 0) {
628 quadrant -= ((quadrant & 2) << 1);
629 return quadrant + twist;
641 double *
min,
double *
max) {
658 long asign_x = (long)(
x < 0.0);
659 long asign_y = (long)(
y < 0.0);
660 long quadrant = -(asign_y << 1) + (asign_y ^ asign_x);
664 double numerator = ((quadrant & 1) != 0) ?
x2 :
y2;
672 std::list<std::pair<const Trk::SpacePoint*,const Trk::SpacePoint*> > &outputListBuffer,
683 double sPhi = (*vCM)(2,2) ;
684 double sTheta = (*vCM)(3,3);
685 double sp = (*vCM)(4,4) ;
687 double ipdelta = sqrt(
m_xiC*sp);
690 tmp_invar_bypass.
invp_min = pTS[4] - ipdelta;
691 tmp_invar_bypass.invp_max = pTS[4] + ipdelta;
693 tmp_invar_bypass.invp_min2 = tmp_invar_bypass.invp_min*tmp_invar_bypass.invp_min;
694 tmp_invar_bypass.invp_max2 = tmp_invar_bypass.invp_max*tmp_invar_bypass.invp_max;
696 double theta_center = pTS[3];
697 double theta_delta = sqrt(
m_xiTC*sTheta);
699 double phi_center = pTS[2];
700 double phi_delta = sqrt(
m_xiFC*sPhi);
703 &(tmp_invar_bypass.min_theta), &(tmp_invar_bypass.max_theta));
705 &(tmp_invar_bypass.min_phi), &(tmp_invar_bypass.max_phi));
713 double H[3];
double gP[3] = {x0,y0,
z0};
718 if (fieldCondObj ==
nullptr) {
723 fieldCondObj->getInitializedCache (fieldCache);
731 std::list<std::pair<const Trk::SpacePoint*,int> >
::iterator r0,r0e,
r,
re,
rb;
737 int fmin=
phi;
int fmax=
phi;
739 for(
int f=fmin;
f<=fmax; ++
f) {
748 for(; r0!=r0e; ++r0){
749 if((((*r0).first)->r() >
m_r1max) ||
750 (((*r0).first)->r() <
m_r2min)) {
759 int fmin=
phi;
int fmax=
phi;
760 for(
int f=fmin;
f<=fmax; ++
f) {
769 for(; r0!=r0e; ++r0){
770 if((((*r0).first)->r()>
m_r1max) || (((*r0).first)->r()<
m_r2min)) {
789 std::vector<bypass_struct> tmp_prod_bypass;
790 std::vector<const Trk::SpacePoint *> vrp;
791 std::vector<double> rk;
792 std::vector<long> geo_info;
793 std::vector<double> zSP;
794 tmp_prod_bypass.reserve(spcount);
795 vrp.reserve(spcount);
797 geo_info.reserve(spcount);
798 zSP.reserve(spcount);
801 for (;
r !=
re; ++
r) {
804 geo_info.push_back((*r).second);
806 rk.push_back(vrpi->
r());
812 double Z = zSPi -
z0;
814 double RR =
X*
X +
Y*
Y;
821 tmp_prod_bypass.emplace_back();
822 tmp_prod_bypass.back().X =
X;
823 tmp_prod_bypass.back().Y =
Y;
824 tmp_prod_bypass.back().Z = Z;
826 tmp_prod_bypass.back().R = R;
827 tmp_prod_bypass.back().invR = invR;
829 tmp_prod_bypass.back().a =
a;
830 tmp_prod_bypass.back().b =
b;
838 for (
long i = 0;
i < (long)spcount;
i++) {
841 for (
long j =
i + 1; j < (long)spcount; j++) {
844 outputListBuffer.emplace_back(
up, SpToPair);
847 outputListBuffer.emplace_back(
up,
up);
852 for (
long i = 0;
i < (long)spcount;
i++) {
860 long geoi = geo_info[
i];
861 int isBU = (geoi >> 4)-3;
862 int eleU = geoi & 15;
864 for (
long j =
i + 1; j < (long)spcount; j++) {
868 long geoj = geo_info[j];
869 int isBB = (geoj >> 4)-3;
870 int eleB = geoj & 15;
880 int Bd = (isBU - isBB) | (isBB - isBU);
881 int Ed = (eleB - eleU);
882 int BUzero = (isBU | -isBU);
883 if (((BUzero | ~Bd) & (Bd | Ed) & (((
unsigned)(-1) >> 1) + 1))
893 if (dZ < dz_min || dZ > dz_max) {
897 if(!
cutTPb(tmp_invar_bypass, tmp_prod_bypass,
i, j,
H[2])) {
902 outputListBuffer.emplace_back(
up, SpToPair);
905 outputListBuffer.emplace_back(
up,
up);
921 const std::vector<bypass_struct> &tmp_prod_bypass,
922 long bSP1,
long bSP2,
double H)
const
925 double inv_r2 = tmp_prod_bypass[bSP2].invR;
926 double inv_r1 = tmp_prod_bypass[bSP1].invR;
927 double r1 = tmp_prod_bypass[bSP1].R;
929 double inv_rr2 = inv_r2*inv_r2;
930 double x2 = tmp_prod_bypass[bSP2].X;
931 double y2 = tmp_prod_bypass[bSP2].Y;
932 double a1 = tmp_prod_bypass[bSP1].a;
933 double b1 = tmp_prod_bypass[bSP1].b;
935 double u2 = (a1*
x2 + b1*
y2)*inv_rr2;
936 double v2 = (a1*
y2 - b1*
x2)*inv_rr2;
938 double A =
v2/(u2 - inv_r1);
939 double B = 2.0*(
v2 - A*u2);
940 double CC = B*B/(1.0 + A*A);
941 double rcrc =
CC*r1*r1;
942 double z1 = tmp_prod_bypass[bSP1].Z;
943 double T = -z1/(r1*(1.0 + 0.04*rcrc));
945 if(
H==0.)
return false;
947 double invpSignature = B*
H;
949 double invP2 =
CC/(0.03*0.03*
H*
H*(1.0 + T*T));
955 double invp_min = tmp_invar_bypass.
invp_min;
956 double invp_max = tmp_invar_bypass.
invp_max;
958 double invp_min2 = tmp_invar_bypass.
invp_min2;
959 double invp_max2 = tmp_invar_bypass.
invp_max2;
962 if (invpSignature < 0 || invP2 < invp_min2) {
967 if (invpSignature < 0 && invP2 > invp_min2) {
972 if (invpSignature >= 0 && invP2 > invp_max2) {
977 if (invpSignature >= 0 || invP2 < invp_max2) {
985 double tmin = tmp_invar_bypass.
min_theta;
986 double tmax = tmp_invar_bypass.
max_theta;
989 #ifndef ANGLE_DISCO_COMPAT
991 if (theta_rating >= 0) {
999 if (tmin + tmax <= 0) {
1010 if (theta_rating < tmin || theta_rating > tmax) {
1014 double phi_rating =
rotrating(-(b1 + a1*A), -(a1 - b1*A));
1015 double pmin = tmp_invar_bypass.
min_phi;
1016 double pmax = tmp_invar_bypass.
max_phi;
1019 #ifndef ANGLE_DISCO_COMPAT
1021 if (phi_rating >= 0) {
1029 if (pmin + pmax <= 0) {
1040 return phi_rating >= pmin && phi_rating <= pmax;
1061 id=
c1->detectorElement()->identify();