17 const std::string&
name,
43 if (
stationName.substr(0,3)==
"BML" && stationEta==7) ilay+=2;
47 double R=std::sqrt(gPosX*gPosX+gPosY*gPosY);
48 double Phi=std::atan2(gPosY,gPosX);
67 std::vector<double>& phi_outer,
70 std::vector<TrigL2MuonSA::ClusterPattern> crPatterns;
72 if( !patfinder(crPatterns, rpcLayerClusters) )
return false;
73 removeSimilarRoad(crPatterns);
75 if( !crPat.isGoodFit )
continue;
76 phi_middle.push_back(crPat.phi_middle);
77 phi_outer.push_back(crPat.phi_outer);
78 ATH_MSG_DEBUG(
"phi_middle/phi_outer = " << crPat.phi_middle <<
"/" << crPat.phi_outer);
91 std::vector<std::list<double>> * rpc_x;
95 if (rpc_x->at(6).size()+rpc_x->at(7).size()>0) l_start_max=5;
97 for (
int l_start=0; l_start<=l_start_max; l_start++){
105 unsigned int pat=(1<<l_start);
108 double current_x =*i_start;
109 int l_current = l_start;
112 ATH_MSG_DEBUG(
"patfinder_cluster: l_start = "<< l_start <<
" x= " << current_x
113 <<
" pat= " << (std::bitset<8>)
pat);
117 bool skipLayer =
false;
118 for (
int l_test=l_start+1; l_test<N_layers; l_test++){
119 ATH_MSG_DEBUG(
"start searching the clusters in RPC plane, l_test = " << l_test);
124 double delta_layer=999;
126 for(
int ilayer = 0; ilayer < 2; ilayer++){
130 if (!deltaOK( l_current,l_test + ilayer,current_x,*i_test,iphi,delta))
continue;
131 if(ilayer == 0)n_layer++;
132 else if(ilayer == 1)n_layer_upper++;
134 if (delta<delta_layer) {
141 ATH_MSG_DEBUG(
"the minimum delta was found in upper layer, update info");
148 if (n_layer>0 || n_layer_upper>0) {
149 int l_result = l_test + layerID;
154 if (l_start<4&&l_result>=4&&delta_layer<dMO){
156 }
else if (l_start<2&&l_result>=2&&l_result<4&&delta_layer<dMM) {
158 }
else if (l_start>=4&&l_start<5&&l_result>=6&&delta_layer<dMM) {
163 ATH_MSG_DEBUG(
" l_test = "<< l_test+layerID <<
" n_layer= "<< n_layer
164 <<
" x= " << current_x <<
" pat= " << (std::bitset<8>)
pat);
166 else if(layerID == 1){
167 ATH_MSG_DEBUG(
" l_test = "<< l_test+layerID <<
" n_layer_upper= "<< n_layer_upper
168 <<
" x= " << current_x <<
" pat= " << (std::bitset<8>)
pat);
171 else if(l_test % 2 == 1){
174 double delta_layer=999;
179 if (!deltaOK( l_current,l_test,current_x,*i_test,iphi,delta))
continue;
182 if (delta<delta_layer) {
194 if (l_start<4&&l_test>=4&&delta_layer<dMO){
196 }
else if (l_start<2&&l_test>=2&&l_test<4&&delta_layer<dMM) {
198 }
else if (l_start>=4&&l_start<5&&l_test>=6&&delta_layer<dMM) {
203 ATH_MSG_DEBUG(
" l_test = "<< l_test <<
" n_layer= "<< n_layer
204 <<
" x= " << current_x <<
" pat= " << (std::bitset<8>)
pat);
220 for(
int i = 0;
i < 8;
i++){
223 crPatterns.push_back(crPat);
227 return crPatterns.size() > 0;
233 std::vector<std::vector<double>>& bw,
236 std::vector<TrigL2MuonSA::ClusterPattern> crPatterns;
238 if( !patfinder_forEta(crPatterns, rpcLayerClusters) )
return false;
239 removeSimilarRoad(crPatterns);
241 if( !crPat.isGoodFit )
continue;
242 for(
int i=0;
i<3;
i++){
243 aw[
i].push_back(crPat.aw[
i]);
244 bw[
i].push_back(crPat.bw[
i]);
246 ATH_MSG_DEBUG(
"aw[" <<
i <<
"]/bw[" <<
i <<
"] = " << crPat.aw[
i] <<
"/" << crPat.bw[
i]);
259 std::vector<std::list<double>> * rpc_x;
262 if(rpc_x->at(6).size()+rpc_x->at(7).size() >0) layer_end = 7;
267 for (
int l_start=0; l_start<layer_end; l_start++){
276 unsigned int pat=(1<<l_start);
279 double aw[3] = {0., 0., 0. };
280 double bw[3] = {0., 0., 0. };
281 double current_x =*i_start;
282 int l_current = l_start;
286 <<
" pat= " << (std::bitset<8>)
pat);
290 bool skipLayer =
false;
291 for (
int l_test=l_start+1; l_test<=layer_end; l_test++){
292 ATH_MSG_DEBUG(
"start searching the clusters in RPC plane, l_test = " << l_test);
297 double delta_layer=999;
299 for(
int ilayer = 0; ilayer < 2; ilayer++){
303 if (!deltaOK( l_current,l_test + ilayer,current_x,*i_test,iphi,delta))
continue;
304 if(ilayer == 0) n_layer++;
305 else if(ilayer == 1) n_layer_upper++;
307 if (delta<delta_layer) {
314 ATH_MSG_DEBUG(
"the minimum delta was found in upper layer, update info");
321 if (n_layer>0 || n_layer_upper>0) {
322 int l_result = l_test + layerID;
327 if (l_start<4&&l_result>=4&&delta_layer<dMO){
329 }
else if (l_start<2&&l_result>=2&&l_result<4&&delta_layer<dMM) {
331 }
else if (l_start>=4&&l_start<5&&l_result>=6&&delta_layer<dMM) {
336 ATH_MSG_DEBUG(
" l_test = "<< l_test+layerID <<
" n_layer= "<< n_layer
337 <<
" x= " << current_x <<
" pat= " << (std::bitset<8>)
pat);
339 else if(layerID == 1){
340 ATH_MSG_DEBUG(
" l_test = "<< l_test+layerID <<
" n_layer_upper= "<< n_layer_upper
341 <<
" x= " << current_x <<
" pat= " << (std::bitset<8>)
pat);
344 else if(l_test % 2 == 1){
347 double delta_layer=999;
352 if (!deltaOK( l_current,l_test,current_x,*i_test,iphi,delta))
continue;
355 if (delta<delta_layer) {
367 if (l_start<4&&l_test>=4&&delta_layer<dMO){
369 }
else if (l_start<2&&l_test>=2&&l_test<4&&delta_layer<dMM) {
371 }
else if(l_start>=4&&l_start<5&&l_test>=6&&delta_layer<dMM) {
376 ATH_MSG_DEBUG(
" l_test = "<< l_test <<
" n_layer= "<< n_layer
377 <<
" x= " << current_x <<
" pat= " << (std::bitset<8>)
pat);
390 abcal(
pat,
index, aw, bw, rpcLayerClusters);
391 for(
int i = 0;
i < 3;
i++){
395 for(
int i = 0;
i < 8;
i++){
398 crPatterns.push_back(crPat);
402 return crPatterns.size() > 0;
427 const double delta_gasgap_eta = 0.01;
428 const double delta_lowpt_eta = 0.05;
429 const double delta_highpt_eta = 0.1;
430 const double delta_feet_eta = 0.05;
432 const double delta_gasgap_phi = 0.01;
433 const double delta_lowpt_phi = 0.03;
434 const double delta_highpt_phi = 0.04;
435 const double delta_feet_phi = 0.03;
439 else delta=std::abs(
x2-
x1);
450 delta_max=delta_gasgap_phi;
451 }
else if (
l1<2&&
l2<4) {
452 delta_max=delta_lowpt_phi;
453 }
else if (l1<4&&l2>=4) {
454 delta_max=delta_highpt_phi;
455 }
else if (l1<6&&l1>=4&&
l2>=6) {
456 delta_max=delta_feet_phi;
460 delta_max=delta_gasgap_eta;
461 }
else if (l1<2&&l2>=2&&
l2<4) {
462 delta_max=delta_lowpt_eta;
463 }
else if (l1<4&&l2>=4) {
464 delta_max=delta_highpt_eta;
465 }
else if (l1<6&&l1>=4&&
l2>=6) {
466 delta_max=delta_feet_eta;
471 return delta<delta_max;
480 double DeltaPhi, temp_phi;
484 DeltaPhi= 999; temp_phi=9999;
485 for(
int inum=0;inum < 8;inum++){
486 temp_phi = std::abs((inum *
M_PI/4.0 )- calibPhi);
487 DeltaPhi =
std::min(temp_phi, DeltaPhi);
489 }
else if(std::string::npos !=
stationName.rfind(
'S') ||
492 DeltaPhi= 999; temp_phi=9999;
494 for(
int inum=0;inum < 8;inum++){
495 temp_phi = std::abs(inum *(
M_PI/4.0 )+(
M_PI/8.0) - calibPhi);
496 DeltaPhi =
std::min(temp_phi, DeltaPhi);
510 std::vector<std::vector<double> > * rpc_R;
511 std::vector<std::vector<double> > * rpc_Z;
514 double R[8]={0,0,0,0,0,0,0,0};
515 double Z[8]={0,0,0,0,0,0,0,0};
518 int hot_min[3]={999,999,999};
519 int hot_max[3]={-999,-999,-999};
523 for(
int i=0;
i<8;
i++){
524 if(
i != 0) bit = bit << 1;
525 if((result_pat & bit)==
false)
continue;
529 if(
i < hot_min[0]) hot_min[0] =
i;
530 if(
i < hot_min[1]) hot_min[1] =
i;
531 if(1 <
i && out_counter <1) hot_min[2] =
i;
537 if(hot_max[2] <
i ) hot_max[2] =
i;
539 if(1 <
i) out_counter++;
544 bool refitFlag =
false;
545 if((hot_max[1]-hot_min[1] == 1) && (hot_min[1] == 0 || hot_min[1] == 2)){
547 R_refit = (R[hot_max[1]]+R[hot_min[1]])/2;
548 Z_refit = (Z[hot_max[1]]+Z[hot_min[1]])/2;
551 unsigned int inn_bit;
553 if((result_pat & inn_bit)==inn_bit){
554 R[hot_min[0]] = (R[0]+R[1])/2.0;
555 Z[hot_min[0]] = (Z[0]+Z[1])/2.0;
558 if((result_pat & inn_bit)==inn_bit){
559 R[hot_max[0]] = (R[2]+R[3])/2.0;
560 Z[hot_max[0]] = (Z[2]+Z[3])/2.0;
563 unsigned int mid_bit;
565 if((result_pat & mid_bit)==mid_bit){
566 R[hot_min[1]] = (R[0]+R[1])/2.0;
567 Z[hot_min[1]] = (Z[0]+Z[1])/2.0;
570 if((result_pat & mid_bit)==mid_bit){
571 R[hot_max[1]] = (R[2]+R[3])/2.0;
572 Z[hot_max[1]] = (Z[2]+Z[3])/2.0;
575 unsigned int out_bit;
577 if((result_pat & out_bit)==out_bit){
578 R[hot_min[2]] = (R[2]+R[3])/2.0;
579 Z[hot_min[2]] = (Z[2]+Z[3])/2.0;
583 if((result_pat & out_bit)==out_bit){
584 R[hot_max[2]] = (R[4]+R[5])/2.0;
585 Z[hot_max[2]] = (Z[4]+Z[5])/2.0;
589 if((result_pat & out_bit)==out_bit){
590 R[hot_max[2]] = (R[6]+R[7])/2.0;
591 Z[hot_max[2]] = (Z[6]+Z[7])/2.0;
595 double theta_m,theta_t, theta_f;
596 if((result_pat & inn_bit)==inn_bit){
597 theta_m = std::atan2(R[hot_min[0]],Z[hot_min[0]]);
598 theta_t = std::atan2(R[hot_max[0]]-R[hot_min[0]],Z[hot_max[0]]-Z[hot_min[0]]);
599 theta_f = (theta_m+theta_t)/2.0;
602 bw[0] = R[hot_min[0]] - Z[hot_min[0]]*aw[0];
606 aw[0] = Z[hot_min[0]] / R[hot_min[0]];
609 aw[0] = Z[hot_max[0]] / R[hot_max[0]];
614 for(
int i=1;
i<3;
i++){
615 if(hot_max[
i]!=-999 && hot_min[
i]!=999){
616 if(std::abs(Z[hot_max[
i]] - Z[hot_min[
i]]) >
ZERO_LIMIT) {
617 aw[
i] = (R[hot_max[
i]]- R[hot_min[
i]]) / (Z[hot_max[
i]]-Z[hot_min[
i]]);
618 bw[
i] = R[hot_max[
i]] - Z[hot_max[
i]]*aw[
i];
621 aw[
i] = Z[hot_min[
i]] / R[hot_min[
i]];
624 aw[
i] = Z[hot_max[
i]] / R[hot_max[
i]];
630 aw[
i] = Z[hot_min[
i]] / R[hot_min[
i]];
632 }
else if(hot_max[
i]!=-999){
633 aw[
i] = Z[hot_max[
i]] / R[hot_max[
i]];
637 if(hot_max[
i]!=-999){
638 aw[
i] = Z[hot_max[
i]] / R[hot_max[
i]];
640 }
else if(hot_min[
i]!=999){
641 aw[
i] = Z[hot_min[
i]] / R[hot_min[
i]];
652 aw[1] = Z_refit/R_refit;
654 ATH_MSG_DEBUG(
"the result of refit : aw/bw = " << aw[1] <<
"/" << bw[1]);
666 ATH_MSG_DEBUG(
"============= setGroup start ========================");
667 setGroup(nGroup, crPatterns);
669 ATH_MSG_DEBUG(
"============= selectGoodFit start ========================");
670 selectGoodFit(nGroup, crPatterns);
677 std::vector<TrigL2MuonSA::ClusterPattern>& crPatterns)
const
680 crPatterns.at(0).group = 0;
681 if(crPatterns.size() > 1){
682 for(
unsigned int iClus_start = 1; iClus_start < crPatterns.size(); iClus_start++){
683 ATH_MSG_DEBUG(
"checked road : clusterID = {" << crPatterns.at(iClus_start).clustersID[0] <<
"," << crPatterns.at(iClus_start).clustersID[1] <<
"," << crPatterns.at(iClus_start).clustersID[2] <<
"," << crPatterns.at(iClus_start).clustersID[3] <<
"," << crPatterns.at(iClus_start).clustersID[4] <<
"," << crPatterns.at(iClus_start).clustersID[5] <<
"," << crPatterns.at(iClus_start).clustersID[6] <<
"," << crPatterns.at(iClus_start).clustersID[7] <<
"}");
684 for(
int igroup = 0; igroup < nGroup; igroup++){
685 bool isDiffGroupFlag =
false;
686 int countDiffId_min = 9999;
687 for(
unsigned int iClus_test = 0; iClus_test < crPatterns.size(); iClus_test++){
688 if(crPatterns.at(iClus_test).group != igroup)
continue;
690 bool isDiffFlag =
false;
691 ATH_MSG_DEBUG(
"the compared road : clusterID = {" << crPatterns.at(iClus_test).clustersID[0] <<
"," << crPatterns.at(iClus_test).clustersID[1] <<
"," << crPatterns.at(iClus_test).clustersID[2] <<
"," << crPatterns.at(iClus_test).clustersID[3] <<
"," << crPatterns.at(iClus_test).clustersID[4] <<
"," << crPatterns.at(iClus_test).clustersID[5] <<
"," << crPatterns.at(iClus_test).clustersID[6] <<
"," << crPatterns.at(iClus_test).clustersID[7] <<
"}");
692 for(
int iLay = 0; iLay < 8; iLay++){
693 if(crPatterns.at(iClus_test).clustersID[iLay] > -1 && crPatterns.at(iClus_start).clustersID[iLay] > -1){
694 if(crPatterns.at(iClus_test).clustersID[iLay] != crPatterns.at(iClus_start).clustersID[iLay]) countDiffId++;
697 ATH_MSG_DEBUG(
"the number of different id's clusters = " << countDiffId);
698 if(countDiffId > 1){ isDiffFlag =
true;}
699 else{
if(countDiffId_min > countDiffId) countDiffId_min = countDiffId;}
700 if(isDiffFlag) isDiffGroupFlag =
true;
702 if(!isDiffGroupFlag){
704 crPatterns.at(iClus_start).groupCand.emplace(igroup, countDiffId_min);
707 if(crPatterns.at(iClus_start).groupCand.empty()){
708 ATH_MSG_DEBUG(
"this road is accepted, Group No. " << nGroup);
709 crPatterns.at(iClus_start).group = nGroup;
713 ATH_MSG_DEBUG(
"this road is denied, searching the appropriate group......");
716 for(
auto itGrp = crPatterns.at(iClus_start).groupCand.begin(); itGrp != crPatterns.at(iClus_start).groupCand.end(); ++itGrp){
717 ATH_MSG_DEBUG(
"group No." << itGrp->first <<
", number of different ID." << itGrp->second);
718 if(minDiff > (itGrp->second)){
719 theGroup = itGrp->first;
720 minDiff = itGrp->second;
723 ATH_MSG_DEBUG(
"the group of this road is defined as No." << theGroup);
724 crPatterns.at(iClus_start).group = theGroup;
732 std::vector<TrigL2MuonSA::ClusterPattern>& crPatterns)
const
735 for(
int iGroup = 0; iGroup < nGroup; iGroup++){
736 std::vector<TrigL2MuonSA::ClusterPattern> crpat_group;
738 int Nclus_max = -999;
740 if(
pat.group != iGroup)
continue;
741 for(
int ilay = 0; ilay < 8; ilay++){
742 if(
pat.clustersID[ilay] > -1)
pat.nclusters++;
744 if(Nclus_max <
pat.nclusters) Nclus_max =
pat.nclusters;
745 crpat_group.push_back(
pat);
749 double smallestdMM = 999999;
750 double smallestdMO = 999999;
755 if(Nclus_max == grpat.nclusters){
756 if(grpat.dMM < smallestdMM ||
757 (grpat.dMM == smallestdMM && grpat.dMO < smallestdMO)){
759 smallestdMM = grpat.
dMM;
760 smallestdMO = grpat.dMO;
767 ATH_MSG_DEBUG(
"bestPattern aw[1]/bw[1] = " << bestPat.
aw[1] <<
"/" << bestPat.
bw[1] <<
", pat aw[1]/bw[1] = " <<
pat.aw[1] <<
"/" <<
pat.bw[1]);
768 pat.isGoodFit =
true;