395 std::vector<const InDet::TRT_DriftCircle*> dc;
396 std::list<const InDet::TRT_DriftCircle*>::iterator it,itE;
398 dc.reserve(event_data.
m_sectors[endcap][zslice][sector].size());
399 itE=event_data.
m_sectors[endcap][zslice][sector].end();
400 for(it=event_data.
m_sectors[endcap][zslice][sector].begin();it!=itE;++it){
407 std::vector<const InDet::TRT_DriftCircle*>::iterator vit,vitE;
413 for(;vit!=vitE;++vit){
414 int straw =
m_trtid->straw((*vit)->identify());
415 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
424 if(dc.size()>=40)
return false;
432 for(;vit!=vitE;++vit){
433 int straw =
m_trtid->straw((*vit)->identify());
434 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
443 shift=(phimax+phimin)/2.-M_PI_4;
444 ATH_MSG_VERBOSE(
"Phimin="<<phimin<<
" Phimax="<<phimax<<
" -> shift = "<<shift);
447 if(phimin<-M_PI_2 && phimax>M_PI_2){
449 ATH_MSG_VERBOSE(
"Boundary between pi and -pi!!! use the following shift: "<<shift);
454 for(vit=dc.begin();vit!=vitE;++vit){
455 int straw =
m_trtid->straw((*vit)->identify());
456 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
458 double orig=
sc.phi();
460 double corr=orig-shift;
475 double p_best[3]={0,0,0};
478 for(
int i=0;i<
count;i++){
479 for(
int j=i+1;j<
count;j++){
487 p[1]=event_data.
m_a_z[i];
516 for(
auto & i : muster)
520 std::vector<const InDet::TRT_DriftCircle*> *seed=
new std::vector<const InDet::TRT_DriftCircle*>;
522 for(
int zsl=zslice-1;zsl<=zslice+1;zsl++){
523 for(
int ps=sector-1;ps<=sector+1;ps++){
526 if(zsl<0 || zsl>=20)
continue;
530 else if(ps2>15) ps2-=16;
532 for(it=event_data.
m_sectors[endcap][zsl][ps2].begin();it!=event_data.
m_sectors[endcap][zsl][ps2].end();++it){
533 int straw =
m_trtid->straw((*it)->identify());
534 const Amg::Vector3D&
sc = (*it)->detectorElement()->strawCenter(straw);
536 double pred_phi=
sc.z()*p_best[0]+p_best[1];
537 double corr=
sc.phi()-p_best[2];
540 if(
sc.z()==p_best[1]) {
550 if(std::abs(
phidiff(pred_phi,corr))<=4./650.){
551 seed->push_back(*it);
552 if(
sc.z()<zmin) zmin=
sc.z();
553 if(
sc.z()>zmax) zmax=
sc.z();
554 muster[zsl-zslice+1][ps-sector+1]=1;
560 std::vector<const InDet::TRT_DriftCircle*>::iterator vit,vitE;
566 ATH_MSG_VERBOSE(
"\t"<<muster[0][0]<<
" "<<muster[1][0]<<
" "<<muster[2][0]);
567 ATH_MSG_VERBOSE(
"\t"<<muster[0][1]<<
" "<<muster[1][1]<<
" "<<muster[2][1]);
568 ATH_MSG_VERBOSE(
"\t"<<muster[0][2]<<
" "<<muster[1][2]<<
" "<<muster[2][2]);
571 if(muster[2][0] || muster[2][1] || muster[2][2]){
575 for(
int ps=sector-2;ps<=sector+2;ps++){
578 if(zsl<0 || zsl>=20)
continue;
582 else if(ps2>15) ps2-=16;
584 for(it=event_data.
m_sectors[endcap][zsl][ps2].begin();it!=event_data.
m_sectors[endcap][zsl][ps2].end();++it){
585 int straw =
m_trtid->straw((*it)->identify());
586 const Amg::Vector3D&
sc = (*it)->detectorElement()->strawCenter(straw);
588 double pred_phi=
sc.z()*p_best[0]+p_best[1];
589 double corr=
sc.phi()-p_best[2];
592 if(
sc.z()==p_best[1]) {
602 if(std::abs(
phidiff(pred_phi,corr))<=4./650.){
604 if(
sc.z()<zmin) zmin=
sc.z();
605 if(
sc.z()>zmax) zmax=
sc.z();
606 seed->push_back(*it);
612 if(muster[0][0] || muster[0][1] || muster[0][2]){
616 for(
int ps=sector-2;ps<=sector+2;ps++){
619 if(zsl<0 || zsl>=20)
continue;
623 else if(ps2>15) ps2-=16;
625 for(it=event_data.
m_sectors[endcap][zsl][ps2].begin();it!=event_data.
m_sectors[endcap][zsl][ps2].end();++it){
626 int straw =
m_trtid->straw((*it)->identify());
627 const Amg::Vector3D&
sc = (*it)->detectorElement()->strawCenter(straw);
629 double pred_phi=
sc.z()*p_best[0]+p_best[1];
630 double corr=
sc.phi()-p_best[2];
633 if(
sc.z()==p_best[1]) {
643 if(std::abs(
phidiff(pred_phi,corr))<=4./650.){
645 if(
sc.z()<zmin) zmin=
sc.z();
646 if(
sc.z()>zmax) zmax=
sc.z();
647 seed->push_back(*it);
665 for(;vit!=vitE;++vit){
666 int straw =
m_trtid->straw((*vit)->identify());
667 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
672 else if(
phi>15 )
phi = 0 ;
676 int zslic=int((std::abs(
sc.z())-800.)/100.);
684 std::list<const InDet::TRT_DriftCircle*>::iterator lit,litE;
688 for(;lit!=litE;++lit){
693 int straw =
m_trtid->straw((*lit)->identify());
694 const Amg::Vector3D&
sc = (*lit)->detectorElement()->strawCenter(straw);
699 else if(
phi>15 )
phi = 0 ;
702 int zsl=int((std::abs(
sc.z())-800.)/100.);
704 if(std::abs(zsl-zslice)<2){
705 double pred_phi=
sc.z()*p_best[0]+p_best[1];
706 double corr=
sc.phi()-p_best[2];
709 if(
sc.z()==p_best[1]) {
719 if(std::abs(
phidiff(pred_phi,corr))<=4./650.){
720 if(
sc.z()>zmin &&
sc.z()<zmax){
721 seed->push_back(*lit);
734 event_data.
m_seeds.push_back(seed);
812 std::vector<const InDet::TRT_DriftCircle*>::iterator vit,vitE;
818 for(;vit!=vitE;++vit){
819 int straw =
m_trtid->straw((*vit)->identify());
820 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
822 if(
sc.z()<zmin) zmin=
sc.z();
823 if(
sc.z()>zmax) zmax=
sc.z();
832 const auto cosPhi{std::cos(
sc.phi())};
846 shift=(phimax+phimin)/2.-M_PI_4;
847 ATH_MSG_VERBOSE(
"Phimin="<<phimin<<
" Phimax="<<phimax<<
" shift="<<shift);
850 if(phimin<-M_PI_2 && phimax>M_PI_2){
852 ATH_MSG_VERBOSE(
"Boundary between pi and -pi!!! use the following shift: "<<shift);
858 for(
int i=0;i<
count;i++){
859 double orig=event_data.
m_a_phi[i];
861 double corr=orig-shift;
866 event_data.
m_a_tan[i]=std::tan(corr);
867 const auto cosCorr{std::cos(corr)};
868 event_data.
m_a_tan_err[i]=(1.15/700.)/(cosCorr*cosCorr);
874 std::list<const InDet::TRT_DriftCircle*>::iterator lit,litE;
880 std::vector<const InDet::TRT_DriftCircle*> tobeadded;
883 for(;lit!=litE;++lit){
884 int straw =
m_trtid->straw((*lit)->identify());
885 const Amg::Vector3D&
sc = (*lit)->detectorElement()->strawCenter(straw);
887 double fitted_phi=fit->Eval(
sc.z(),0.,0.);
890 if (fitted_phi >
M_PI) fitted_phi = std::fmod(fitted_phi+
M_PI,2.*
M_PI)-
M_PI;
891 else if(fitted_phi <-
M_PI) fitted_phi = std::fmod(fitted_phi-
M_PI,2.*
M_PI)+
M_PI;
899 for(;vit!=vitE && new_hit;++vit){
905 ATH_MSG_VERBOSE(
"\t\t good hit matched! fitted_phi="<<fitted_phi<<
" z=" <<
sc.z());
907 if(
sc.z()>zmin-200 &&
sc.z()<zmax+200){
908 if(
sc.z()<zmin) zmin=
sc.z();
909 if(
sc.z()>zmax) zmax=
sc.z();
911 seed->push_back(*lit);
914 tobeadded.push_back(*lit);
922 int index1=-1,index2=-1;
928 for(vit=tobeadded.begin();vit!=tobeadded.end();++vit){
929 int straw =
m_trtid->straw((*vit)->identify());
930 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
933 if(
sc.z()<zmin &&
sc.z()>z1) {
937 if(
sc.z()>zmax && index2==-1) {
946 for(
int i=index2;i<
count;i++){
947 int straw =
m_trtid->straw(tobeadded[i]->identify());
948 const Amg::Vector3D&
sc = tobeadded[i]->detectorElement()->strawCenter(straw);
951 seed->push_back(tobeadded[i]);
960 for(
int i=index1;i>=0;i--){
961 int straw =
m_trtid->straw(tobeadded[i]->identify());
962 const Amg::Vector3D&
sc = tobeadded[i]->detectorElement()->strawCenter(straw);
965 seed->push_back(tobeadded[i]);
984 for(;vit!=vitE;++vit){
985 int straw =
m_trtid->straw((*vit)->identify());
986 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
995 const auto cosPhi{std::cos(
sc.phi())};
1009 shift=(phimax+phimin)/2.-M_PI_4;
1010 ATH_MSG_VERBOSE(
"Phimin="<<phimin<<
" Phimax="<<phimax<<
" shift="<<shift);
1013 if(phimin<-M_PI_2 && phimax>M_PI_2){
1015 ATH_MSG_VERBOSE(
"Boundary between pi and -pi!!! use the following shift: "<<shift);
1020 for(
int i=0;i<
count;i++){
1021 double orig=event_data.
m_a_phi[i];
1022 double corr=orig-shift;
1028 event_data.
m_a_tan[i]=std::tan(corr);
1029 const auto cosCorr{std::cos(corr)};
1030 event_data.
m_a_tan_err[i]=(1.15/700.)/(cosCorr*cosCorr);
1041 for(;lit!=litE;++lit){
1045 int straw =
m_trtid->straw((*lit)->identify());
1046 const Amg::Vector3D&
sc = (*lit)->detectorElement()->strawCenter(straw);
1049 double phi=
sc.phi();
1050 double fitted_phi=fit->Eval(
sc.z(),0.,0.);
1053 if (fitted_phi >
M_PI) fitted_phi = std::fmod(fitted_phi+
M_PI,2.*
M_PI)-
M_PI;
1054 else if(fitted_phi <-
M_PI) fitted_phi = std::fmod(fitted_phi-
M_PI,2.*
M_PI)+
M_PI;
1057 if(
z*event_data.
m_a_z[0]<0)
continue;
1063 for(;vit!=vitE && new_hit;++vit){
1069 if(
sc.z()>zmin-50 &&
sc.z()<zmax+50){
1070 ATH_MSG_VERBOSE(
"\t\t noise hit matched! fitted_phi="<<fitted_phi<<
" z=" <<
sc.z());
1071 seed->push_back(*lit);
1073 ATH_MSG_VERBOSE(
"\t\t noise hit matched but too far away! fitted_phi="<<fitted_phi<<
" z=" <<
sc.z());
1083 Amg::Vector3D firststraw=((*seed)[0]->detectorElement()->strawCenter(
m_trtid->straw((*seed)[0]->identify()) ));
1084 Amg::Vector3D laststraw=((*seed)[seed->size()-1]->detectorElement()->strawCenter(
m_trtid->straw((*seed)[seed->size()-1]->identify()) ));
1086 double z2=laststraw.z();
1087 double yfirst=firststraw.y();
1088 double ylast=laststraw.y();
1096 if (std::abs(yfirst-ylast)>50){
1104 if ((yfirst>0 && z1<0) || (yfirst<0 && z1>0))
std::sort(seed->begin(),seed->end(),
CompareDCz);
1107 firststraw=(*seed)[0]->detectorElement()->strawCenter(
m_trtid->straw((*seed)[0]->identify()) );
1108 laststraw=(*seed)[seed->size()-1]->detectorElement()->strawCenter(
m_trtid->straw((*seed)[seed->size()-1]->identify()) );
1114 Theta=
M_PI-std::atan2(400.,std::abs(z1-z2));
1117 Theta=std::atan2(400.,std::abs(z1-z2));
1121 double globaly=((*seed)[0]->detectorElement()->strawCenter(
m_trtid->straw((*seed)[0]->identify()) )).y();
1122 double firstphi=((*seed)[0]->detectorElement()->strawCenter(
m_trtid->straw((*seed)[0]->identify()) )).phi();
1125 ATH_MSG_VERBOSE(
"Number of tube hits matching straight line: "<<seed->size());
1130 const Amg::Vector3D& sc_first = ((*seed)[0]->detectorElement()->strawCenter(
m_trtid->straw((*seed)[0]->identify()) ));
1131 const Amg::Vector3D& sc_last = ((*seed)[seed->size()-1]->detectorElement()->strawCenter(
m_trtid->straw((*seed)[seed->size()-1]->identify()) ));
1134 double tx1,tx2,ty1,ty2;
1136 tx1=1050*std::cos(sc_first.phi());
1137 ty1=1050*std::sin(sc_first.phi());
1139 tx2=650*std::cos(sc_last.phi());
1140 ty2=650*std::sin(sc_last.phi());
1142 double tphi=std::atan2(ty2-ty1,tx2-tx1);
1167 ATH_MSG_VERBOSE(
"globaly = "<<globaly<<
" phi="<<firstphi<<
" theta="<<Theta<<
" --> state = "<<state);
1174 for(;vit!=vitE;++vit){
1176 int straw =
m_trtid->straw((*vit)->identify());
1177 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
1194 for(;vit!=vitE;++vit){
1195 int straw =
m_trtid->straw((*vit)->identify());
1196 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
1198 double fitted_phi=fit->Eval(
sc.z(),0.,0.);
1201 if (fitted_phi >
M_PI) fitted_phi = std::fmod(fitted_phi+
M_PI,2.*
M_PI)-
M_PI;
1202 else if(fitted_phi <-
M_PI) fitted_phi = std::fmod(fitted_phi-
M_PI,2.*
M_PI)+
M_PI;
1205 if(fitted_phi<
sc.phi())
sign=-1;
1209 double drifte = 2*std::sqrt((*vit)->localCovariance()(0,0));
1211 double straw_r=640+400./std::abs(z2-z1)*std::abs(
sc.z()-z1);
1213 double dphi=
sign*driftr/straw_r;
1221 const auto cosPhiMinShift{std::cos(event_data.
m_a_phi[
count]-shift)};
1242 for(;vit!=vitE;++vit){
1243 int straw =
m_trtid->straw((*vit)->identify());
1244 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
1245 double fitted_phi=fit->Eval(
sc.z(),0.,0.);
1249 double drifte = 2*std::sqrt((*vit)->localCovariance()(0,0));
1252 if(fitted_phi<
sc.phi())
sign=-1;
1254 double straw_r=640+400./std::abs(z2-z1)*std::abs(
sc.z()-z1);
1255 double dphi=
sign*driftr/straw_r;
1261 if (
msgLvl(MSG::VERBOSE))
msg()<<
"z="<<
sc.z()<<
" phi="<<
sc.phi()<<
" fitted_phi = "<<fitted_phi<<
endmsg;
1270 const auto cosPhiMinShift{ std::cos(event_data.
m_a_phi[
count]-shift)};
1293 for(;vit!=vitE;++vit){
1294 int straw =
m_trtid->straw((*vit)->identify());
1295 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
1297 double fitted_phi=fit->Eval(
sc.z(),0.,0.);
1300 if (fitted_phi >
M_PI) fitted_phi = std::fmod(fitted_phi+
M_PI,2.*
M_PI)-
M_PI;
1301 else if(fitted_phi <-
M_PI) fitted_phi = std::fmod(fitted_phi-
M_PI,2.*
M_PI)+
M_PI;
1304 double drifte = 2*std::sqrt((*vit)->localCovariance()(0,0));
1307 if(fitted_phi<
sc.phi())
sign=-1;
1309 double straw_r=640+400./std::abs(z2-z1)*std::abs(
sc.z()-z1);
1310 double dphi=
sign*driftr/straw_r;
1331 if(
count>=400)
return;
1344 double initial_r=-10.;
1345 double initial_locz=0.;
1348 for(;vit!=vitE;++vit){
1350 (&((*vit)->detectorElement())->surface( (*vit)->identify()));
1353 int straw =
m_trtid->straw((*vit)->identify());
1354 const Amg::Vector3D&
sc = (*vit)->detectorElement()->strawCenter(straw);
1361 if(std::abs(z2-z1)>0.000001){
1363 locz=400./std::abs(z2-z1)*std::abs(
z-z1)-200.;
1365 locz=200.-400./std::abs(z2-z1)*std::abs(
z-z1);
1368 double fitted_phi=fit->Eval(
z,0.,0.);
1371 if (fitted_phi >
M_PI) fitted_phi = std::fmod(fitted_phi+
M_PI,2.*
M_PI)-
M_PI;
1372 else if(fitted_phi <-
M_PI) fitted_phi = std::fmod(fitted_phi-
M_PI,2.*
M_PI)+
M_PI;
1374 double fitted_r=(
phidiff(fitted_phi,
sc.phi()))*(840+locz);
1375 double temp_phi=fitted_phi;
1377 if(initial_r==-10. && std::abs(fitted_r)<4.0){
1400 bool useDrift=
false;
1404 double drifte = 2*std::sqrt((*vit)->localCovariance()(0,0));
1407 if(fitted_phi<
sc.phi())
sign=-1;
1409 double straw_r=640+400./std::abs(z2-z1)*std::abs(
sc.z()-z1);
1410 double dphi=
sign*driftr/straw_r;
1412 if(std::abs(
phidiff(fitted_phi,
sc.phi()-dphi)) < 3* drifte/straw_r){
1414 chi2+=(std::abs(fitted_r)-std::abs(driftr))*(std::abs(fitted_r)-std::abs(driftr))/(drifte*drifte);
1422 rio.push_back(
m_riomakerD->correct(*(*vit),
Tp, Gaudi::Hive::currentContext()));
1425 chi2+=(fitted_r/1.15)*(fitted_r/1.15);
1427 rio.push_back(
m_riomakerN->correct(*(*vit),
Tp, Gaudi::Hive::currentContext()));
1442 if(state==2 || state==3){
1458 rio.push_back(pseudo);
1467 const Trk::Surface * sur = &((*seed)[0]->detectorElement())->surface((*seed)[0]->identify());
1472 if(firstphi>0) firstphi=-firstphi;
1481 std::array<Trk::DefinedParameter,5> defPar = {dp0,dp1,dp2,dp3,dp4};
1488 double universal=1.15;
1493 universal*universal, 0., 0., 0., 0.,
1494 0. , 160000./12., 0., 0., 0.,
1495 0. , 0., 0.1, 0., 0.,
1496 0. , 0., 0., 1., 0.,
1497 0. , 0., 0., 0., 1.;