31 return StatusCode::SUCCESS;
36 std::vector<TrigL2MuonSA::TrackPattern> &v_trackPatterns,
44 if( !cscHits.empty() ){
49 int hash_clusters[32]={0};
52 for(
unsigned int iclu=0; iclu<cscHits.size(); ++iclu){
63 if(0<=module_hash && 32>module_hash){
64 clusters[module_hash][cathodelayer].push_back( cscHit );
65 hash_clusters[module_hash]=1;
73 int hashSPs[2]={999,999};
76 bool found_segment=
false;
77 for(
int ihash=0; ihash<2; ++ihash){
78 if(found_segment)
break;
80 int hashSP=hashSPs[ihash];
81 if(hashSP>32)
continue;
87 track.hashID_CSC = hashSP;
93 bool &large_dphidz =
track.large_dPhidZ;
94 double &outerCorFactor =
track.outerCorFactor;
97 double tgcmid1z = tgcFitResult.
tgcMid1[3];
98 double tgcmid2z = tgcFitResult.
tgcMid2[3];
99 double phimiddle = tgcFitResult.
phi;
100 double dPhidz = tgcFitResult.
dPhidZ;
101 if( 0.75
e-6<std::abs(dPhidz) ) large_dphidz=
true;
102 double tgcmidZ = (tgcmid1z+tgcmid2z)/2.;
103 double outerz = outerSP->
Z;
109 double CSCZ=cscsegment_ext.
z();
110 double PhiAtCsc = phimiddle;
114 superPoint->
Z = CSCZ;
115 superPoint->
R = CSCSPR;
121 <<
",CSCR=" << CSCSPR <<
",CSCZ=" << CSCZ
122 <<
",Slope=" << cscsegment_ext.
slopeRZ() <<
",Intercept=" << cscsegment_ext.
interceptRZ()
123 <<
",nHitsEta=" << cscsegment_ext.
nHitEta() <<
",Chi2="<< cscsegment_ext.
chiSquare());
126 double phiouter = phimiddle+std::abs(outerz-tgcmidZ)*dPhidz;
147 ATH_MSG_DEBUG(
"################################## make_segment #####################################");
149 std::vector<localCscHit> hits_loc_eta[4], hits_loc_phi[4],emp;
151 for(
int i =0;
i<4;++
i){
174 gToLocal=translation*rotPIamg*rotYamg*rotZamg;
190 for (
unsigned int clyr=0; clyr<8; ++clyr) {
191 for (
unsigned int ihit=0; ihit<
clusters[clyr].size(); ++ihit) {
225 Amg::Vector3D seg_pos_loc, seg_dir_loc,seg_pos_loc_noip, seg_dir_loc_noip;
227 local2dSegment seg2d_eta ,seg2d_phi, seg2d_eta_noip, seg2d_phi_noip;
244 Amg::Vector3D seg_dir_noip = lToGlobal.rotation()*seg_dir_loc_noip;
248 cscsegment.
set(seg_pos,seg_dir, seg2d_eta.
chi2, seg2d_phi.
chi2);
251 cscsegment_noip.
set(seg_pos_noip,seg_dir_noip, seg2d_eta_noip.
chi2, seg2d_phi_noip.
chi2);
267 std::vector<int> hit_lyr;
271 for (
int i=0;
i<4; ++
i ){
272 if( 0==hits_loc[
i].
size() ) ++nohit;
275 std::vector<local2dSegment> seg2d_4hitCollection,seg2d_3hitCollection;
276 seg2d_4hitCollection.clear(); seg2d_3hitCollection.clear();
277 std::vector<localCscHit> hits_loc_copy[4];
278 for (
int i=0;
i<4;++
i) hits_loc_copy[
i] = hits_loc[
i];
289 }
else if(1==nohit) {
300 for(
unsigned int iseg4=0; iseg4< seg2d_4hitCollection.size(); ++iseg4){
302 if( std::abs( seg2d_4hitCollection[iseg4].
residual ) < std::abs(seg2d.
residual) ){
303 seg2d=seg2d_4hitCollection[iseg4];
308 for(
unsigned int iseg3=0; iseg3< seg2d_3hitCollection.size(); ++iseg3){
310 if( std::abs( seg2d_3hitCollection[iseg3].
residual ) < std::abs(seg2d.
residual) ){
311 seg2d=seg2d_3hitCollection[iseg3];
326 std::vector<localCscHit> hits_loc[4],
327 std::vector<local2dSegment> &seg2d_4hitCollection,
331 std::vector<localCscHit> hit_fit;
333 for (
unsigned int ihit0=0; ihit0<hits_loc[0].size(); ++ihit0) {
334 for (
unsigned int ihit1=0; ihit1<hits_loc[1].size(); ++ihit1) {
335 for (
unsigned int ihit2=0; ihit2<hits_loc[2].size(); ++ihit2) {
336 for (
unsigned int ihit3=0; ihit3<hits_loc[3].size(); ++ihit3) {
340 hit_fit.push_back(ip_loc);
341 hit_fit.push_back(hits_loc[0][ihit0]);
342 hit_fit.push_back(hits_loc[1][ihit1]);
343 hit_fit.push_back(hits_loc[2][ihit2]);
344 hit_fit.push_back(hits_loc[3][ihit3]);
352 seg2d_tmp.
localHits.push_back(hits_loc[0][ihit0]);
353 seg2d_tmp.
localHits.push_back(hits_loc[1][ihit1]);
354 seg2d_tmp.
localHits.push_back(hits_loc[2][ihit2]);
355 seg2d_tmp.
localHits.push_back(hits_loc[3][ihit3]);
357 hits_loc[0][ihit0].enabled=
false;
358 hits_loc[1][ihit1].enabled=
false;
359 hits_loc[2][ihit2].enabled=
false;
360 hits_loc[3][ihit3].enabled=
false;
362 seg2d_4hitCollection.push_back(seg2d_tmp);
373 std::vector<localCscHit> hit_loc_left[4];
374 for (
unsigned int ilyr=0;ilyr<4; ++ilyr){
375 for(
unsigned int ihit=0; ihit < hits_loc[ilyr].size(); ++ihit){
377 if (
true==hits_loc[ilyr][ihit].enabled ){
378 hit_loc_left[ilyr].push_back(hits_loc[ilyr][ihit]);
383 for(
int ilyr=0; ilyr<4; ++ilyr) hits_loc[ilyr]=hit_loc_left[ilyr];
393 const std::vector<localCscHit> hits_loc[4],
394 std::vector<local2dSegment> &seg2d_3hitCollection,
400 for (
int ilyr=0; ilyr<4; ++ilyr ){
401 if( 0==hits_loc[ilyr].
size() ){
409 std::vector<localCscHit> hit_fit;
412 int hit_lyrA[4] = {1, 2, 3, 0};
413 int hit_lyrB[4] = {2, 3, 0, 1};
414 int hit_lyrC[4] = {3, 0, 1, 2};
416 for(
int lyrcomb=0; lyrcomb<4; ++lyrcomb){
418 if(0<=empty_lyr && empty_lyr!=lyrcomb)
continue;
420 for (
unsigned int ihitA=0; ihitA<hits_loc[hit_lyrA[lyrcomb]].size(); ++ihitA) {
421 for (
unsigned int ihitB=0; ihitB<hits_loc[hit_lyrB[lyrcomb]].size(); ++ihitB) {
422 for (
unsigned int ihitC=0; ihitC<hits_loc[hit_lyrC[lyrcomb]].size(); ++ihitC) {
425 hit_fit.push_back(ip_loc);
426 hit_fit.push_back(hits_loc[hit_lyrA[lyrcomb]][ihitA]);
427 hit_fit.push_back(hits_loc[hit_lyrB[lyrcomb]][ihitB]);
428 hit_fit.push_back(hits_loc[hit_lyrC[lyrcomb]][ihitC]);
436 seg2d_tmp.
localHits.push_back(hits_loc[hit_lyrA[lyrcomb]][ihitA]);
437 seg2d_tmp.
localHits.push_back(hits_loc[hit_lyrB[lyrcomb]][ihitB]);
438 seg2d_tmp.
localHits.push_back(hits_loc[hit_lyrC[lyrcomb]][ihitC]);
439 seg2d_3hitCollection.push_back(seg2d_tmp);
473 for (
unsigned int ihit=0; ihit< hits_fit.size(); ++ihit) {
476 double x= hits_fit[ihit].loc_z;
477 double y= (measphi==0) ? hits_fit[ihit].loc_y : hits_fit[ihit].loc_x;
478 double err= hits_fit[ihit].error;
484 if( !hits_fit[ihit].isIP ){
486 aver_res +=
w*hits_fit[ihit].residual;
498 for (
unsigned int ihit=0; ihit< hits_fit.size(); ++ihit) {
500 double x= hits_fit[ihit].loc_z;
501 double y= (measphi==0) ? hits_fit[ihit].loc_y : hits_fit[ihit].loc_x;
502 double err = hits_fit[ihit].error;
504 Stt +=
w*(
x-Sx/
S)*(
x-Sx/
S);
505 aStt +=
w*
y*(
x-Sx/
S);
515 a = seg2d.
a = aStt/Stt;
516 b = seg2d.
b = (Sy-Sx*
a)/
S;
522 seg2d.
chi2 = Syy +
a*
a*Sxx + 2*
b*
a*Sx +
b*
b*
S - 2*
b*Sy - 2*
a*Sxy;
537 int nhit_e=seg2d_eta.
nhit;
538 int nhit_p=seg2d_phi.
nhit;
539 double a_eta=seg2d_eta.
a;
540 double b_eta=seg2d_eta.
b;
541 double a_phi=seg2d_phi.
a;
542 double b_phi=seg2d_phi.
b;
543 double rzshift=seg2d_eta.
zshift;
544 double phizshift=seg2d_phi.
zshift;
551 ATH_MSG_DEBUG(
"rzshift=" << rzshift <<
" phizshift=" << phizshift <<
" diff=" << (rzshift-phizshift)
552 <<
" angle=" << ( 0.5*
M_PI -
std::atan(a_phi) ) <<
" b_phi=" << b_phi );
555 double norm = std::sqrt( a_phi*a_phi + a_eta*a_eta + 1 );
561 << a_eta <<
" a_phi=" << a_phi <<
" chi2_eta=" << seg2d_eta.
chi2 <<
" chi2_phi=" << seg2d_phi.
chi2 );
563 double aver_z=0.5*(rzshift+phizshift);
582 const int hash_clusters[32])
const
587 for(
unsigned int imod=0; imod<32;++imod){
589 if( 0==hash_clusters[imod] )
continue;
594 ATH_MSG_DEBUG(
"getModuleSP()::(phi,side) modlue:(" << phiMod <<
"," << stationeta <<
") tgcroad:(" << tgcFitResult.
phi <<
"," <<
side <<
")");
595 if( std::abs(dphi)>
M_PI/8. ||
side != stationeta)
continue;
600 if(imod<16 && phibin>7){
602 }
else if( imod >=16 && phibin<7){
608 }
else if (7==phibin) {
612 }
else if( imod >=16 && 0== muroad.
LargeSmall){
620 ATH_MSG_DEBUG(
"getModuleSP::Normal sector=" << mod_hashes[0] <<
" overlap sector=" << mod_hashes[1]);
633 double a0=mu_seg->
px(), a1=mu_seg->
py(), a2=mu_seg->
pz();
634 double b0=mu_seg->
x(), b1=mu_seg->
y(),b2=mu_seg->
z();
635 double t = ( alpha-(
n(0)*b0+
n(1)*b1+
n(2)*b2) )/(
n(0)*
a0+
n(1)*a1+
n(2)*a2 );
641 cscsegment.
set(x0,
x1,
x2,
a0,a1,a2,chisquare, chisquare_phi);
652 for(
unsigned int ilyr=0; ilyr<4; ++ilyr){
653 for (
unsigned int ihit=0; ihit<localHits[ilyr].size(); ++ihit) {
656 <<
" x=" << locHit.
loc_x <<
" y=" << locHit.
loc_y <<
" z=" << locHit.
loc_z
691 double r = std::sqrt(
x*
x +
y*
y );
710 double r = std::sqrt(
x()*
x() +
y()*
y() );
724 bool eta_clean=
false;
725 bool phi_clean=
false;
730 return eta_clean && phi_clean;