19 const std::string&
name,
44 if (
stationName.substr(0,3)==
"BML" && stationEta==7) ilay+=2;
48 double R=std::sqrt(gPosX*gPosX+gPosY*gPosY);
49 const double Phi=std::atan2(gPosY,gPosX);
73 if (patfinder(
true,
pattern, phi_middle,phi_outer, result_dMO, rpcLayerHits)>=2)
found=
true;
83 double result_delta[3]={9999,9999,9999};
85 if( patfinder_forEta(
false,
pattern, aw, bw, result_delta, rpcLayerHits)>=2)
found=
true;
92 unsigned int &result_pat,
98 const std::vector<std::list<double>> * rpc_x;
102 if(rpc_x->at(6).size()+rpc_x->at(7).size() >0) layer_end = 7;
110 size_t result_index[8]={};
113 for (
int l_start=0; l_start<layer_end; l_start++){
117 for (std::list<double>::const_iterator i_start=rpc_x->at(l_start).begin(); i_start!=rpc_x->at(l_start).end(); ++i_start){
119 unsigned int pat=(1<<l_start);
122 double current_x =*i_start;
123 int l_current = l_start;
127 ATH_MSG_DEBUG(
"patfinder: l_start = "<< l_start <<
" x= " << current_x
128 <<
" pat= " << (std::bitset<8>)
pat);
132 for (
int l_test=l_start+1; l_test<=layer_end; l_test++){
135 double delta_layer=999;
137 for (std::list<double>::const_iterator i_test=rpc_x->at(l_test).begin(); i_test!=rpc_x->at(l_test).end(); ++i_test){
140 if (deltaOK(l_current,l_test,current_x,*i_test,iphi,delta)){
143 if (delta<delta_layer) {
155 if (l_start<4&&l_test>=4&&delta_layer<dMO){
157 }
else if (l_start<2&&l_test>=2&&l_test<4&&delta_layer<dMM) {
159 }
else if (l_start>=4&&l_start<5&&l_test>=6&&delta_layer<dMM) {
164 ATH_MSG_DEBUG(
"patfinder: l_test = "<< l_test <<
" n_layer= "<< n_layer
165 <<
" x= " << current_x <<
" pat= " << (std::bitset<8>)
pat);
174 for(
int i=0;
i<8;
i++) result_index[
i]=
index[
i];
175 }
else if (n_hits==n_max) {
177 if (dMM<result_dist[1]||(dMM==result_dist[1]&&dMO<result_dist[2])){
181 for(
int i=0;
i<8;
i++) result_index[
i]=
index[
i];
188 abcal(result_pat, result_index, result_aw, result_bw, rpcLayerHits);
189 ATH_MSG_DEBUG(
"patfinder: BEST pat= " << (std::bitset<8>)result_pat
190 <<
" dMM= "<<result_dist[1] <<
" dMO= "<<result_dist[2]);
201 unsigned int &result_pat,
207 const int N_layers=8;
209 const std::vector<std::list<double>> * rpc_x;
217 if (rpc_x->at(6).size()+rpc_x->at(7).size()>0) l_start_max=5;
223 double result_dMM=9999;
229 for (
int l_start=0; l_start<=l_start_max; l_start++){
231 for (std::list<double>::const_iterator i_start=rpc_x->at(l_start).begin(); i_start!=rpc_x->at(l_start).end(); ++i_start){
233 unsigned int pat=(1<<l_start);
237 double current_x =*i_start;
238 int l_current = l_start;
239 ATH_MSG_DEBUG(
"patfinder: l_start = "<< l_start <<
" x= " << current_x
240 <<
" pat= " << (std::bitset<8>)
pat);
244 for (
int l_test=l_start+1; l_test<N_layers; l_test++){
247 double delta_layer=999;
249 for (std::list<double>::const_iterator i_test=rpc_x->at(l_test).begin(); i_test!=rpc_x->at(l_test).end(); ++i_test){
252 if (deltaOK(l_current,l_test,current_x,*i_test,iphi,delta)){
255 if (delta<delta_layer) {
266 if (l_start<4&&l_test>=4&&delta_layer<dMO){
268 }
else if (l_start<2&&l_test>=2&&l_test<4&&delta_layer<dMM) {
270 }
else if (l_start>=4&&l_start<5&&l_test>=6&&delta_layer<dMM) {
274 ATH_MSG_DEBUG(
"patfinder: l_test = "<< l_test <<
" n_layer= "<< n_layer
275 <<
" x= " << current_x <<
" pat= " << (std::bitset<8>)
pat);
285 }
else if (n_hits==n_max) {
287 if (dMM<result_dMM||(dMM==result_dMM&&dMO<result_dMO)){
298 ATH_MSG_DEBUG(
"patfinder: BEST pat= " << (std::bitset<8>)result_pat
299 <<
" dMM= "<<result_dMM <<
" dMO= "<<result_dMO
300 <<
" x0= "<<result_x <<
" x1= "<<result_x1);
327 const double delta_gasgap_eta = 0.01;
328 const double delta_lowpt_eta = 0.05;
329 const double delta_highpt_eta = 0.1;
330 const double delta_feet_eta = 0.05;
332 const double delta_gasgap_phi = 0.01;
333 const double delta_lowpt_phi = 0.03;
334 const double delta_highpt_phi = 0.04;
335 const double delta_feet_phi = 0.03;
339 else delta=std::abs(
x2-
x1);
350 delta_max=delta_gasgap_phi;
351 }
else if (
l1<2&&
l2<4) {
352 delta_max=delta_lowpt_phi;
353 }
else if (l1<4&&l2>=4) {
354 delta_max=delta_highpt_phi;
355 }
else if (l1<6&&l1>=4&&
l2>=6) {
356 delta_max=delta_feet_phi;
360 delta_max=delta_gasgap_eta;
361 }
else if (l1<2&&l2>=2&&
l2<4) {
362 delta_max=delta_lowpt_eta;
363 }
else if (l1<4&&l2>=4) {
364 delta_max=delta_highpt_eta;
365 }
else if (l1<6&&l1>=4&&
l2>=6) {
366 delta_max=delta_feet_eta;
373 if (delta<delta_max) OK=
true;
383 double DeltaPhi, temp_phi;
387 DeltaPhi= 999; temp_phi=9999;
388 for(
int inum=0;inum < 8;inum++){
389 temp_phi = std::abs((inum *
M_PI/4.0 )- calibPhi);
390 if(temp_phi < DeltaPhi) DeltaPhi = temp_phi;
392 }
else if(std::string::npos !=
stationName.rfind(
'S') ||
395 DeltaPhi= 999; temp_phi=9999;
397 for(
int inum=0;inum < 8;inum++){
398 temp_phi = std::abs(inum *(
M_PI/4.0 )+(
M_PI/8.0) - calibPhi);
399 if(temp_phi < DeltaPhi) DeltaPhi = temp_phi;
403 double calibR = R *
std::cos(DeltaPhi);
418 const std::vector<std::vector<double> > * rpc_R;
419 const std::vector<std::vector<double> > * rpc_Z;
422 double R[8]={0,0,0,0,0,0,0,0};
423 double Z[8]={0,0,0,0,0,0,0,0};
426 int hot_min[3]={999,999,999};
427 int hot_max[3]={-999,-999,-999};
431 for(
int i=0;
i<8;
i++){
432 if(
i != 0) bit = bit << 1;
433 if((result_pat & bit)==
false)
continue;
437 if(
i < hot_min[0]) hot_min[0] =
i;
438 if(
i < hot_min[1]) hot_min[1] =
i;
439 if(1 <
i && out_counter <1) hot_min[2] =
i;
445 if(hot_max[2] <
i ) hot_max[2] =
i;
447 if(1 <
i) out_counter++;
450 unsigned int inn_bit;
452 if((result_pat & inn_bit)==inn_bit){
453 R[hot_min[0]] = (R[0]+R[1])/2.0;
454 Z[hot_min[0]] = (Z[0]+Z[1])/2.0;
457 if((result_pat & inn_bit)==inn_bit){
458 R[hot_max[0]] = (R[2]+R[3])/2.0;
459 Z[hot_max[0]] = (Z[2]+Z[3])/2.0;
462 unsigned int mid_bit;
464 if((result_pat & mid_bit)==mid_bit){
465 R[hot_min[1]] = (R[0]+R[1])/2.0;
466 Z[hot_min[1]] = (Z[0]+Z[1])/2.0;
469 if((result_pat & mid_bit)==mid_bit){
470 R[hot_max[1]] = (R[2]+R[3])/2.0;
471 Z[hot_max[1]] = (Z[2]+Z[3])/2.0;
474 unsigned int out_bit;
476 if((result_pat & out_bit)==out_bit){
477 R[hot_min[2]] = (R[2]+R[3])/2.0;
478 Z[hot_min[2]] = (Z[2]+Z[3])/2.0;
482 if((result_pat & out_bit)==out_bit){
483 R[hot_max[2]] = (R[4]+R[5])/2.0;
484 Z[hot_max[2]] = (Z[4]+Z[5])/2.0;
488 if((result_pat & out_bit)==out_bit){
489 R[hot_max[2]] = (R[6]+R[7])/2.0;
490 Z[hot_max[2]] = (Z[6]+Z[7])/2.0;
494 double theta_m,theta_t, theta_f;
495 if((result_pat & inn_bit)==inn_bit){
496 theta_m = std::atan2(R[hot_min[0]],Z[hot_min[0]]);
497 theta_t = std::atan2(R[hot_max[0]]-R[hot_min[0]],Z[hot_max[0]]-Z[hot_min[0]]);
498 theta_f = (theta_m+theta_t)/2.0;
501 bw[0] = R[hot_min[0]] - Z[hot_min[0]]*aw[0];
505 aw[0] = Z[hot_min[0]] / R[hot_min[0]];
508 aw[0] = Z[hot_max[0]] / R[hot_max[0]];
513 for(
int i=1;
i<3;
i++){
514 if(hot_max[
i]!=-999 && hot_min[
i]!=999){
515 if(std::abs(Z[hot_max[
i]] - Z[hot_min[
i]]) >
ZERO_LIMIT) {
516 aw[
i] = (R[hot_max[
i]]- R[hot_min[
i]]) / (Z[hot_max[
i]]-Z[hot_min[
i]]);
517 bw[
i] = R[hot_max[
i]] - Z[hot_max[
i]]*aw[
i];
520 aw[
i] = Z[hot_min[
i]] / R[hot_min[
i]];
523 aw[
i] = Z[hot_max[
i]] / R[hot_max[
i]];
529 aw[
i] = Z[hot_min[
i]] / R[hot_min[
i]];
531 }
else if(hot_max[
i]!=-999){
532 aw[
i] = Z[hot_max[
i]] / R[hot_max[
i]];
536 if(hot_max[
i]!=-999){
537 aw[
i] = Z[hot_max[
i]] / R[hot_max[
i]];
539 }
else if(hot_min[
i]!=999){
540 aw[
i] = Z[hot_min[
i]] / R[hot_min[
i]];