272 MsgStream log(
msgSvc(), name());
276 if( !init_mucMagneticField() ) {
277 cerr <<
" STOP! " << endl;
291 if(m_gridDistance == 5) {
294 m_Q_1.reserve(201250);
295 m_P_1.reserve(201250);
296 m_Q_2.reserve(201250);
297 m_P_2.reserve(201250);
298 m_Q_TE.reserve(176608);
299 m_P_TE.reserve(176608);
301 if(m_gridDistance == 10) {
304 m_Q_1.reserve(27082);
305 m_P_1.reserve(27082);
306 m_Q_2.reserve(27082);
307 m_P_2.reserve(27082);
308 m_Q_TE.reserve(23833);
309 m_P_TE.reserve(23833);
316 setenv(
"BEPCII_INFO.BPR_PRB", BPR_PRB, 1);
317 setenv(
"BEPCII_INFO.BER_PRB", BER_PRB, 1);
318 int ssm_curr = int (
current[0]);
326 log << MSG::INFO <<
"SSM current: " <<
current[0] <<
" SCQL current: " <<
current[1] <<
" SCQR current: " <<
current[2] <<
" in Run " <<
runNo << endreq;
330 cout <<
"SSM current: " <<
current[0] <<
" SCQL current: " <<
current[1]
331 <<
" SCQR current: " <<
current[2] <<
" in Run " <<
runNo << endl;
339 if(((ssm_curr >= 3367) && (ssm_curr <= 3370) && ((scql_curr+scqr_curr)/2 < m_Cur_SCQ1_89))) {
340 m_zfield = -1.0*tesla;
342 m_filename += std::string(
"/dat/2008-05-27BESIII-field-Mode2.dat");
344 log << MSG::INFO <<
"Select field map: " << m_filename << endreq;
346 cout <<
"Select field map: " << m_filename << endl;
349 if(((former_m_filename ==
"First Run") || (former_m_filename != m_filename))&&(
m_readOneTime ==
true))
351 former_m_filename = m_filename;
355 StatusCode status = parseFile();
357 if ( !status.isSuccess() ) {
358 log << MSG::DEBUG <<
"Magnetic field parse failled" << endreq;
362 cout <<
"Magnetic field parse failled" << endl;
371 if(m_gridDistance == 5) {
375 if(m_gridDistance == 10) {
381 m_filename += std::string(
"/dat/2008-05-27BESIII-field-Mode3.dat");
383 log << MSG::INFO <<
"Select field map: " << m_filename << endreq;
385 cout <<
"Select field map: " << m_filename << endl;
388 if(((former_m_filename ==
"First Run") || (former_m_filename != m_filename))&&(
m_readOneTime ==
true))
390 former_m_filename = m_filename;
394 status = parseFile();
396 if ( !status.isSuccess() ) {
397 log << MSG::DEBUG <<
"Magnetic field parse failled" << endreq;
401 cout <<
"Magnetic field parse failled" << endl;
410 if(m_gridDistance == 5) {
414 if(m_gridDistance == 10) {
419 if(m_Q_2.size() != m_Q_1.size()) {
421 log << MSG::FATAL <<
"The two field maps used in this run are wrong!!!" << endreq;
423 cout <<
"The two field maps used in this run are wrong!!!" << endl;
428 for(
unsigned int iQ = 0; iQ < m_Q_1.size(); iQ++) {
429 double fieldvalue = (m_Q_1[iQ] - m_Q_2[iQ])/(m_Cur_SCQ1_55 - m_Cur_SCQ1_89)*((scql_curr+scqr_curr)/2 - m_Cur_SCQ1_89) + m_Q_2[iQ];
430 m_Q.push_back(fieldvalue);
431 m_P.push_back(m_P_2[iQ]);
435 if(((ssm_curr >= 3367) && (ssm_curr <= 3370) && ((scql_curr+scqr_curr)/2 >= m_Cur_SCQ1_89))){
436 m_zfield = -1.0*tesla;
438 m_filename += std::string(
"/dat/2008-05-27BESIII-field-Mode3.dat");
440 log << MSG::INFO <<
"Select field map: " << m_filename << endreq;
442 cout <<
"Select field map: " << m_filename << endl;
444 if(((former_m_filename ==
"First Run") || (former_m_filename != m_filename))&&(
m_readOneTime ==
true))
446 former_m_filename = m_filename;
450 StatusCode status = parseFile();
452 if ( !status.isSuccess() ) {
453 log << MSG::DEBUG <<
"Magnetic field parse failled" << endreq;
457 cout <<
"Magnetic field parse failled" << endl;
466 if(m_gridDistance == 5) {
470 if(m_gridDistance == 10) {
476 m_filename += std::string(
"/dat/2008-05-27BESIII-field-Mode4.dat");
478 log << MSG::INFO <<
"Select field map: " << m_filename << endreq;
480 cout <<
"Select field map: " << m_filename << endl;
483 if(((former_m_filename ==
"First Run") || (former_m_filename != m_filename))&&(
m_readOneTime ==
true))
485 former_m_filename = m_filename;
489 status = parseFile();
491 if ( !status.isSuccess() ) {
492 log << MSG::DEBUG <<
"Magnetic field parse failled" << endreq;
496 cout <<
"Magnetic field parse failled" << endl;
505 if(m_gridDistance == 5) {
509 if(m_gridDistance == 10) {
515 if(m_Q_2.size() != m_Q_1.size()) {
518 log << MSG::FATAL <<
"The two field maps used in this run are wrong!!!" << endreq;
522 cout <<
"The two field maps used in this run are wrong!!!" << endl;
528 for(
unsigned int iQ = 0; iQ < m_Q_1.size(); iQ++) {
529 double fieldvalue = (m_Q_1[iQ] - m_Q_2[iQ])/(m_Cur_SCQ1_89 - m_Cur_SCQ2_10)*((scql_curr+scqr_curr)/2 - m_Cur_SCQ2_10) + m_Q_2[iQ];
530 m_Q.push_back(fieldvalue);
531 m_P.push_back(m_P_2[iQ]);
534 if((ssm_curr >= 3033) && (ssm_curr <= 3035)) {
535 m_zfield = -0.9*tesla;
537 m_filename += std::string(
"/dat/2008-05-27BESIII-field-Mode7.dat");
539 log << MSG::INFO <<
"Select field map: " << m_filename << endreq;
541 cout <<
"Select field map: " << m_filename << endl;
544 if(((former_m_filename ==
"First Run") || (former_m_filename != m_filename))&&(
m_readOneTime ==
true))
546 former_m_filename = m_filename;
550 StatusCode status = parseFile();
552 if ( !status.isSuccess() ) {
553 log << MSG::DEBUG <<
"Magnetic field parse failled" << endreq;
557 cout <<
"Magnetic field parse failled" << endl;
566 if(m_gridDistance == 5) {
570 if(m_gridDistance == 10) {
576 m_filename += std::string(
"/dat/2008-05-27BESIII-field-Mode8.dat");
578 log << MSG::INFO <<
"Select field map: " << m_filename << endreq;
580 cout <<
"Select field map: " << m_filename << endl;
583 if(((former_m_filename ==
"First Run") || (former_m_filename != m_filename))&&(
m_readOneTime ==
true)){
584 former_m_filename = m_filename;
588 status = parseFile();
590 if ( !status.isSuccess() ) {
591 log << MSG::DEBUG <<
"Magnetic field parse failled" << endreq;
595 cout <<
"Magnetic field parse failled" << endl;
604 if(m_gridDistance == 5) {
608 if(m_gridDistance == 10) {
613 if(m_Q_2.size() != m_Q_1.size()) {
615 log << MSG::FATAL <<
"The two field maps used in this run are wrong!!!" << endreq;
617 cout <<
"The two field maps used in this run are wrong!!!" << endl;
622 for(
unsigned int iQ = 0; iQ < m_Q_1.size(); iQ++) {
623 double fieldvalue = (m_Q_1[iQ] - m_Q_2[iQ])/(m_Cur_SCQ1_55 - m_Cur_SCQ1_89)*((scql_curr+scqr_curr)/2 - m_Cur_SCQ1_89) + m_Q_2[iQ];
624 m_Q.push_back(fieldvalue);
625 m_P.push_back(m_P_2[iQ]);
628 if((!((ssm_curr >= 3367) && (ssm_curr <= 3370)) && !((ssm_curr >= 3033) && (ssm_curr <= 3035))) || scql_curr == 0 || scqr_curr == 0) {
630 log << MSG::FATAL <<
"The current of run " <<
runNo <<
" is abnormal in database, please check it! " << endreq;
631 log << MSG::FATAL <<
"The current of SSM is " << ssm_curr <<
", SCQR is " << scqr_curr <<
", SCQL is " << scql_curr << endreq;
633 cout <<
"The current of run " <<
runNo
634 <<
" is abnormal in database, please check it! " << endl;
635 cout <<
"The current of SSM is " << ssm_curr
636 <<
", SCQR is " << scqr_curr <<
", SCQL is " << scql_curr << endl;
641 if(m_Q.size() == 0) {
643 log << MSG::FATAL <<
"This size of field map vector is ZERO, please check the current of run " <<
runNo <<
" in database!" << endreq;
645 cout <<
"This size of field map vector is ZERO,"
646 <<
" please check the current of run " <<
runNo
647 <<
" in database!" << endl;
652 m_filename_TE = path;
653 if(m_gridDistance == 10) m_filename_TE += std::string(
"/dat/TEMap10cm.dat");
654 if(m_gridDistance == 5) m_filename_TE += std::string(
"/dat/TEMap5cm.dat");
656 log << MSG::INFO <<
"Select field map: " << m_filename_TE << endreq;
658 cout <<
"Select field map: " << m_filename_TE << endl;
660 if(((former_m_filename_TE ==
"First Run") || (former_m_filename_TE != m_filename_TE))&&(
m_readOneTime ==
true))
662 former_m_filename_TE = m_filename_TE;
666 StatusCode status = parseFile_TE();
668 if ( !status.isSuccess() ) {
669 log << MSG::DEBUG <<
"Magnetic field parse failled" << endreq;
673 cout <<
"Magnetic field parse failled" << endl;
677 for (
int iC = 0; iC< 2; ++iC ){
678 m_min_FL[iC] = -90.0*cm;
679 m_max_FL[iC] = m_min_FL[iC]+( m_Nxyz[iC]-1 )* m_Dxyz[iC];
681 m_min_FL_TE[iC] = 0.0*cm;
682 m_max_FL_TE[iC] = m_min_FL_TE[iC]+( m_Nxyz_TE[iC]-1 )* m_Dxyz_TE[iC];
684 m_min_FL[2] = -120.0*cm;
685 m_max_FL[2] = m_min_FL[2]+( m_Nxyz[2]-1 )* m_Dxyz[2];
687 m_min_FL_TE[2] = 0.0*cm;
688 m_max_FL_TE[2] = m_min_FL_TE[2]+( m_Nxyz_TE[2]-1 )* m_Dxyz_TE[2];
1084 if(m_turnOffField ==
true) {
1089 return StatusCode::SUCCESS;
1099 return StatusCode::SUCCESS;
1107 double new_x = -newr.x();
1108 double new_y = newr.y();
1109 double new_z = -newr.z();
1116 if(-2.1*m<r.z() && r.z()<2.1*m && -1.8*m<r.x() && r.x()<1.8*m && -1.8*m<r.y() && r.y()<1.8*m)
1118 if(-1.2*m<r.z()&&r.z()<1.2*m&&0*m<=std::sqrt(r.x()*r.x()+r.y()*r.y())&&std::sqrt(r.x()*r.x()+r.y()*r.y())<0.9*m)
1121 this->fieldGrid( r,
b );
1125 this->fieldGrid_TE( r,
b );
1128 if((fabs(r.z())<=1970*mm && sqrt(r.x()*r.x()+r.y()*r.y()) >= 1740*mm) || (fabs(r.z())>=2050*mm))
1132 int part = 0, layer = 0, mat = 0;
1137 theta = atan2(fabs(r.y()),fabs(r.x()));
1138 if(0<=theta&&theta<
pi/8) {
1139 mr[0] = fabs(r.x()); mr[1] = -fabs(r.y()); mr[2] = fabs(r.z());
1140 if(mr[2]<=1970*mm&&1740*mm<=mr[0]&&mr[0]<=2620*mm){
1142 if(1740*mm<=mr[0]&&mr[0]<1770*mm) { layer = 0; mat = 0; }
1143 if(1770*mm<=mr[0]&&mr[0]<1810*mm) { layer = 0; mat = 1; }
1144 if(1810*mm<=mr[0]&&mr[0]<1840*mm) { layer = 1; mat = 0; }
1145 if(1840*mm<=mr[0]&&mr[0]<1880*mm) { layer = 1; mat = 1; }
1146 if(1880*mm<=mr[0]&&mr[0]<1910*mm) { layer = 2; mat = 0; }
1147 if(1910*mm<=mr[0]&&mr[0]<1950*mm) { layer = 2; mat = 1; }
1148 if(1950*mm<=mr[0]&&mr[0]<1990*mm) { layer = 3; mat = 0; }
1149 if(1990*mm<=mr[0]&&mr[0]<2030*mm) { layer = 3; mat = 1; }
1150 if(2030*mm<=mr[0]&&mr[0]<2070*mm) { layer = 4; mat = 0; }
1151 if(2070*mm<=mr[0]&&mr[0]<2110*mm) { layer = 4; mat = 1; }
1152 if(2110*mm<=mr[0]&&mr[0]<2190*mm) { layer = 5; mat = 0; }
1153 if(2190*mm<=mr[0]&&mr[0]<2230*mm) { layer = 5; mat = 1; }
1154 if(2230*mm<=mr[0]&&mr[0]<2310*mm) { layer = 6; mat = 0; }
1155 if(2310*mm<=mr[0]&&mr[0]<2350*mm) { layer = 6; mat = 1; }
1156 if(2350*mm<=mr[0]&&mr[0]<2430*mm) { layer = 7; mat = 0; }
1157 if(2430*mm<=mr[0]&&mr[0]<2470*mm) { layer = 7; mat = 1; }
1158 if(2470*mm<=mr[0]&&mr[0]<=2620*mm) { layer = 8; mat = 0; }
1165 if(2050*mm<=mr[2]&&mr[2]<2090*mm&&1034*mm<=mr[0]&&mr[0]<=2500*mm){
1166 part = 0; layer = 0; mat = 0;
1173 if(2090*mm<=mr[2]&&mr[2]<2130*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1174 part = 0; layer = 0; mat = 1;
1181 if(2130*mm<=mr[2]&&mr[2]<2170*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1182 part = 0; layer = 1; mat = 0;
1189 if(2170*mm<=mr[2]&&mr[2]<2210*mm&&1100*mm<=mr[0]&&mr[0]<=2500*mm) {
1190 part = 0; layer = 1; mat = 1;
1197 if(2210*mm<=mr[2]&&mr[2]<2240*mm&&1100*mm<mr[0]&&mr[0]<=2500*mm) {
1198 part = 0; layer = 2; mat = 0;
1205 if(2240*mm<=mr[2]&&mr[2]<2280*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1206 part = 0; layer = 2; mat = 1;
1213 if(2280*mm<=mr[2]&&mr[2]<2310*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1214 part = 0; layer = 3; mat = 0;
1221 if(2310*mm<=mr[2]&&mr[2]<2350*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1222 part = 0; layer = 3; mat = 1;
1229 if(2350*mm<=mr[2]&&mr[2]<2380*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1230 part = 0; layer = 4; mat = 0;
1237 if(2380*mm<=mr[2]&&mr[2]<2420*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1238 part = 0; layer = 4; mat = 1;
1245 if(2420*mm<=mr[2]&&mr[2]<2470*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1246 part = 0; layer = 5; mat = 0;
1253 if(2470*mm<=mr[2]&&mr[2]<2510*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1254 part = 0; layer = 5; mat =1;
1261 if(2510*mm<=mr[2]&&mr[2]<2590*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1262 part = 0; layer = 6; mat = 0;
1269 if(2590*mm<=mr[2]&&mr[2]<2630*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1270 part = 0; layer = 6; mat = 1;
1277 if(2630*mm<=mr[2]&&mr[2]<2710*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1278 part = 0; layer = 7; mat = 0;
1285 if(2710*mm<=mr[2]&&mr[2]<2750*mm&&1362*mm<=mr[0]&&mr[0]<=2500*mm) {
1286 part = 0; layer = 7; mat = 1;
1293 if(2750*mm<=mr[2]&&mr[2]<=2800*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1294 part = 0; layer = 8; mat = 0;
1302 if(
pi/8<=theta&&theta<
pi/4) {
1303 mr[0] = fabs(r.x())*
cos(
pi/4)+fabs(r.y())*
sin(
pi/4);
1304 mr[1] = -fabs(r.x())*
sin(
pi/4)+fabs(r.y())*
cos(
pi/4);
1305 mr[2] = fabs(r.z());
1306 if(mr[2]<=1970*mm&&1740*mm<=mr[0]&&mr[0]<=2620*mm) {
1308 if(1740*mm<=mr[0]&&mr[0]<1770*mm) { layer = 0; mat = 0; }
1309 if(1770*mm<=mr[0]&&mr[0]<1810*mm) { layer = 0; mat = 1; }
1310 if(1810*mm<=mr[0]&&mr[0]<1840*mm) { layer = 1; mat = 0; }
1311 if(1840*mm<=mr[0]&&mr[0]<1880*mm) { layer = 1; mat = 1; }
1312 if(1880*mm<=mr[0]&&mr[0]<1910*mm) { layer = 2; mat = 0; }
1313 if(1910*mm<=mr[0]&&mr[0]<1950*mm) { layer = 2; mat = 1; }
1314 if(1950*mm<=mr[0]&&mr[0]<1990*mm) { layer = 3; mat = 0; }
1315 if(1990*mm<=mr[0]&&mr[0]<2030*mm) { layer = 3; mat = 1; }
1316 if(2030*mm<=mr[0]&&mr[0]<2070*mm) { layer = 4; mat = 0; }
1317 if(2070*mm<=mr[0]&&mr[0]<2110*mm) { layer = 4; mat = 1; }
1318 if(2110*mm<=mr[0]&&mr[0]<2190*mm) { layer = 5; mat = 0; }
1319 if(2190*mm<=mr[0]&&mr[0]<2230*mm) { layer = 5; mat = 1; }
1320 if(2230*mm<=mr[0]&&mr[0]<2310*mm) { layer = 6; mat = 0; }
1321 if(2310*mm<=mr[0]&&mr[0]<2350*mm) { layer = 6; mat = 1; }
1322 if(2350*mm<=mr[0]&&mr[0]<2430*mm) { layer = 7; mat = 0; }
1323 if(2430*mm<=mr[0]&&mr[0]<2470*mm) { layer = 7; mat = 1; }
1324 if(2470*mm<=mr[0]&&mr[0]<=2620*mm) { layer = 8; mat = 0; }
1331 if(2050*mm<=mr[2]&&mr[2]<2090*mm&&1034*mm<=mr[0]&&mr[0]<=2500*mm){
1332 part = 0; layer = 0; mat = 0;
1339 if(2090*mm<=mr[2]&&mr[2]<2130*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1340 part = 0; layer = 0; mat = 1;
1347 if(2130*mm<=mr[2]&&mr[2]<2170*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1348 part = 0; layer = 1; mat = 0;
1355 if(2170*mm<=mr[2]&&mr[2]<2210*mm&&1100*mm<=mr[0]&&mr[0]<=2500*mm) {
1356 part = 0; layer = 1; mat = 1;
1363 if(2210*mm<=mr[2]&&mr[2]<2240*mm&&1100*mm<mr[0]&&mr[0]<=2500*mm) {
1364 part = 0; layer = 2; mat = 0;
1371 if(2240*mm<=mr[2]&&mr[2]<2280*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1372 part = 0; layer = 2; mat = 1;
1379 if(2280*mm<=mr[2]&&mr[2]<2310*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1380 part = 0; layer = 3; mat = 0;
1387 if(2310*mm<=mr[2]&&mr[2]<2350*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1388 part = 0; layer = 3; mat = 1;
1395 if(2350*mm<=mr[2]&&mr[2]<2380*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1396 part = 0; layer = 4; mat = 0;
1403 if(2380*mm<=mr[2]&&mr[2]<2420*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1404 part = 0; layer = 4; mat = 1;
1411 if(2420*mm<=mr[2]&&mr[2]<2470*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1412 part = 0; layer = 5; mat = 0;
1419 if(2470*mm<=mr[2]&&mr[2]<2510*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1420 part = 0; layer = 5; mat =1;
1427 if(2510*mm<=mr[2]&&mr[2]<2590*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1428 part = 0; layer = 6; mat = 0;
1435 if(2590*mm<=mr[2]&&mr[2]<2630*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1436 part = 0; layer = 6; mat = 1;
1443 if(2630*mm<=mr[2]&&mr[2]<2710*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1444 part = 0; layer = 7; mat = 0;
1451 if(2710*mm<=mr[2]&&mr[2]<2750*mm&&1362*mm<=mr[0]&&mr[0]<=2500*mm) {
1452 part = 0; layer = 7; mat = 1;
1459 if(2750*mm<=mr[2]&&mr[2]<=2800*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1460 part = 0; layer = 8; mat = 0;
1468 if(
pi/4<=theta&&theta<3*
pi/8) {
1469 mr[0] = fabs(r.x())*
cos(
pi/4)+fabs(r.y())*
sin(
pi/4);
1470 mr[1] = fabs(r.x())*
sin(
pi/4)-fabs(r.y())*
cos(
pi/4);
1471 mr[2] = fabs(r.z());
1472 if(mr[2]<=1970*mm&&1740*mm<=mr[0]&&mr[0]<=2620*mm) {
1474 if(1740*mm<=mr[0]&&mr[0]<1770*mm) { layer = 0; mat = 0; }
1475 if(1770*mm<=mr[0]&&mr[0]<1810*mm) { layer = 0; mat = 1; }
1476 if(1810*mm<=mr[0]&&mr[0]<1840*mm) { layer = 1; mat = 0; }
1477 if(1840*mm<=mr[0]&&mr[0]<1880*mm) { layer = 1; mat = 1; }
1478 if(1880*mm<=mr[0]&&mr[0]<1910*mm) { layer = 2; mat = 0; }
1479 if(1910*mm<=mr[0]&&mr[0]<1950*mm) { layer = 2; mat = 1; }
1480 if(1950*mm<=mr[0]&&mr[0]<1990*mm) { layer = 3; mat = 0; }
1481 if(1990*mm<=mr[0]&&mr[0]<2030*mm) { layer = 3; mat = 1; }
1482 if(2030*mm<=mr[0]&&mr[0]<2070*mm) { layer = 4; mat = 0; }
1483 if(2070*mm<=mr[0]&&mr[0]<2110*mm) { layer = 4; mat = 1; }
1484 if(2110*mm<=mr[0]&&mr[0]<2190*mm) { layer = 5; mat = 0; }
1485 if(2190*mm<=mr[0]&&mr[0]<2230*mm) { layer = 5; mat = 1; }
1486 if(2230*mm<=mr[0]&&mr[0]<2310*mm) { layer = 6; mat = 0; }
1487 if(2310*mm<=mr[0]&&mr[0]<2350*mm) { layer = 6; mat = 1; }
1488 if(2350*mm<=mr[0]&&mr[0]<2430*mm) { layer = 7; mat = 0; }
1489 if(2430*mm<=mr[0]&&mr[0]<2470*mm) { layer = 7; mat = 1; }
1490 if(2470*mm<=mr[0]&&mr[0]<=2620*mm) { layer = 8; mat = 0; }
1497 if(2050*mm<=mr[2]&&mr[2]<2090*mm&&1034*mm<=mr[0]&&mr[0]<=2500*mm){
1498 part = 0; layer = 0; mat = 0;
1505 if(2090*mm<=mr[2]&&mr[2]<2130*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1506 part = 0; layer = 0; mat = 1;
1513 if(2130*mm<=mr[2]&&mr[2]<2170*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1514 part = 0; layer = 1; mat = 0;
1521 if(2170*mm<=mr[2]&&mr[2]<2210*mm&&1100*mm<=mr[0]&&mr[0]<=2500*mm) {
1522 part = 0; layer = 1; mat = 1;
1529 if(2210*mm<=mr[2]&&mr[2]<2240*mm&&1100*mm<mr[0]&&mr[0]<=2500*mm) {
1530 part = 0; layer = 2; mat = 0;
1537 if(2240*mm<=mr[2]&&mr[2]<2280*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1538 part = 0; layer = 2; mat = 1;
1545 if(2280*mm<=mr[2]&&mr[2]<2310*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1546 part = 0; layer = 3; mat = 0;
1553 if(2310*mm<=mr[2]&&mr[2]<2350*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1554 part = 0; layer = 3; mat = 1;
1561 if(2350*mm<=mr[2]&&mr[2]<2380*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1562 part = 0; layer = 4; mat = 0;
1569 if(2380*mm<=mr[2]&&mr[2]<2420*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1570 part = 0; layer = 4; mat = 1;
1577 if(2420*mm<=mr[2]&&mr[2]<2470*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1578 part = 0; layer = 5; mat = 0;
1585 if(2470*mm<=mr[2]&&mr[2]<2510*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1586 part = 0; layer = 5; mat =1;
1593 if(2510*mm<=mr[2]&&mr[2]<2590*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1594 part = 0; layer = 6; mat = 0;
1601 if(2590*mm<=mr[2]&&mr[2]<2630*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1602 part = 0; layer = 6; mat = 1;
1609 if(2630*mm<=mr[2]&&mr[2]<2710*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1610 part = 0; layer = 7; mat = 0;
1617 if(2710*mm<=mr[2]&&mr[2]<2750*mm&&1362*mm<=mr[0]&&mr[0]<=2500*mm) {
1618 part = 0; layer = 7; mat = 1;
1625 if(2750*mm<=mr[2]&&mr[2]<=2800*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1626 part = 0; layer = 8; mat = 0;
1634 if(3*
pi/8<=theta&&theta<
pi/2) {
1635 mr[0] = fabs(r.y()); mr[1] = -fabs(r.x()); mr[2] = fabs(r.z());
1636 if(mr[2]<=1970*mm&&1740*mm<=mr[0]&&mr[0]<=2620*mm) {
1638 if(1740*mm<=mr[0]&&mr[0]<1770*mm) { layer = 0; mat = 0; }
1639 if(1770*mm<=mr[0]&&mr[0]<1810*mm) { layer = 0; mat = 1; }
1640 if(1810*mm<=mr[0]&&mr[0]<1840*mm) { layer = 1; mat = 0; }
1641 if(1840*mm<=mr[0]&&mr[0]<1880*mm) { layer = 1; mat = 1; }
1642 if(1880*mm<=mr[0]&&mr[0]<1910*mm) { layer = 2; mat = 0; }
1643 if(1910*mm<=mr[0]&&mr[0]<1950*mm) { layer = 2; mat = 1; }
1644 if(1950*mm<=mr[0]&&mr[0]<1990*mm) { layer = 3; mat = 0; }
1645 if(1990*mm<=mr[0]&&mr[0]<2030*mm) { layer = 3; mat = 1; }
1646 if(2030*mm<=mr[0]&&mr[0]<2070*mm) { layer = 4; mat = 0; }
1647 if(2070*mm<=mr[0]&&mr[0]<2110*mm) { layer = 4; mat = 1; }
1648 if(2110*mm<=mr[0]&&mr[0]<2190*mm) { layer = 5; mat = 0; }
1649 if(2190*mm<=mr[0]&&mr[0]<2230*mm) { layer = 5; mat = 1; }
1650 if(2230*mm<=mr[0]&&mr[0]<2310*mm) { layer = 6; mat = 0; }
1651 if(2310*mm<=mr[0]&&mr[0]<2350*mm) { layer = 6; mat = 1; }
1652 if(2350*mm<=mr[0]&&mr[0]<2430*mm) { layer = 7; mat = 0; }
1653 if(2430*mm<=mr[0]&&mr[0]<2470*mm) { layer = 7; mat = 1; }
1654 if(2470*mm<=mr[0]&&mr[0]<=2620*mm) { layer = 8; mat = 0; }
1661 if(2050*mm<=mr[2]&&mr[2]<2090*mm&&1034*mm<=mr[0]&&mr[0]<=2500*mm){
1662 part = 0; layer = 0; mat = 0;
1669 if(2090*mm<=mr[2]&&mr[2]<2130*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1670 part = 0; layer = 0; mat = 1;
1677 if(2130*mm<=mr[2]&&mr[2]<2170*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1678 part = 0; layer = 1; mat = 0;
1685 if(2170*mm<=mr[2]&&mr[2]<2210*mm&&1100*mm<=mr[0]&&mr[0]<=2500*mm) {
1686 part = 0; layer = 1; mat = 1;
1693 if(2210*mm<=mr[2]&&mr[2]<2240*mm&&1100*mm<mr[0]&&mr[0]<=2500*mm) {
1694 part = 0; layer = 2; mat = 0;
1701 if(2240*mm<=mr[2]&&mr[2]<2280*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1702 part = 0; layer = 2; mat = 1;
1709 if(2280*mm<=mr[2]&&mr[2]<2310*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1710 part = 0; layer = 3; mat = 0;
1717 if(2310*mm<=mr[2]&&mr[2]<2350*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1718 part = 0; layer = 3; mat = 1;
1725 if(2350*mm<=mr[2]&&mr[2]<2380*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1726 part = 0; layer = 4; mat = 0;
1733 if(2380*mm<=mr[2]&&mr[2]<2420*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1734 part = 0; layer = 4; mat = 1;
1741 if(2420*mm<=mr[2]&&mr[2]<2470*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1742 part = 0; layer = 5; mat = 0;
1749 if(2470*mm<=mr[2]&&mr[2]<2510*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1750 part = 0; layer = 5; mat =1;
1757 if(2510*mm<=mr[2]&&mr[2]<2590*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1758 part = 0; layer = 6; mat = 0;
1765 if(2590*mm<=mr[2]&&mr[2]<2630*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1766 part = 0; layer = 6; mat = 1;
1773 if(2630*mm<=mr[2]&&mr[2]<2710*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1774 part = 0; layer = 7; mat = 0;
1781 if(2710*mm<=mr[2]&&mr[2]<2750*mm&&1362*mm<=mr[0]&&mr[0]<=2500*mm) {
1782 part = 0; layer = 7; mat = 1;
1789 if(2750*mm<=mr[2]&&mr[2]<=2800*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1790 part = 0; layer = 8; mat = 0;
1800 mr[0] = fabs(r.y()); mr[1] = -fabs(r.x()); mr[2] = fabs(r.z());
1801 if(mr[2]<=1970*mm&&1740*mm<=mr[0]&&mr[0]<=2620*mm) {
1803 if(1740*mm<=mr[0]&&mr[0]<1770*mm) { layer = 0; mat = 0; }
1804 if(1770*mm<=mr[0]&&mr[0]<1810*mm) { layer = 0; mat = 1; }
1805 if(1810*mm<=mr[0]&&mr[0]<1840*mm) { layer = 1; mat = 0; }
1806 if(1840*mm<=mr[0]&&mr[0]<1880*mm) { layer = 1; mat = 1; }
1807 if(1880*mm<=mr[0]&&mr[0]<1910*mm) { layer = 2; mat = 0; }
1808 if(1910*mm<=mr[0]&&mr[0]<1950*mm) { layer = 2; mat = 1; }
1809 if(1950*mm<=mr[0]&&mr[0]<1990*mm) { layer = 3; mat = 0; }
1810 if(1990*mm<=mr[0]&&mr[0]<2030*mm) { layer = 3; mat = 1; }
1811 if(2030*mm<=mr[0]&&mr[0]<2070*mm) { layer = 4; mat = 0; }
1812 if(2070*mm<=mr[0]&&mr[0]<2110*mm) { layer = 4; mat = 1; }
1813 if(2110*mm<=mr[0]&&mr[0]<2190*mm) { layer = 5; mat = 0; }
1814 if(2190*mm<=mr[0]&&mr[0]<2230*mm) { layer = 5; mat = 1; }
1815 if(2230*mm<=mr[0]&&mr[0]<2310*mm) { layer = 6; mat = 0; }
1816 if(2310*mm<=mr[0]&&mr[0]<2350*mm) { layer = 6; mat = 1; }
1817 if(2350*mm<=mr[0]&&mr[0]<2430*mm) { layer = 7; mat = 0; }
1818 if(2430*mm<=mr[0]&&mr[0]<2470*mm) { layer = 7; mat = 1; }
1819 if(2470*mm<=mr[0]&&mr[0]<=2620*mm) { layer = 8; mat = 0; }
1826 if(2050*mm<=mr[2]&&mr[2]<2090*mm&&1034*mm<=mr[0]&&mr[0]<=2500*mm){
1827 part = 0; layer = 0; mat = 0;
1834 if(2090*mm<=mr[2]&&mr[2]<2130*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1835 part = 0; layer = 0; mat = 1;
1842 if(2130*mm<=mr[2]&&mr[2]<2170*mm&&1067*mm<=mr[0]&&mr[0]<=2500*mm) {
1843 part = 0; layer = 1; mat = 0;
1850 if(2170*mm<=mr[2]&&mr[2]<2210*mm&&1100*mm<=mr[0]&&mr[0]<=2500*mm) {
1851 part = 0; layer = 1; mat = 1;
1858 if(2210*mm<=mr[2]&&mr[2]<2240*mm&&1100*mm<mr[0]&&mr[0]<=2500*mm) {
1859 part = 0; layer = 2; mat = 0;
1866 if(2240*mm<=mr[2]&&mr[2]<2280*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1867 part = 0; layer = 2; mat = 1;
1874 if(2280*mm<=mr[2]&&mr[2]<2310*mm&&1133*mm<=mr[0]&&mr[0]<=2500*mm) {
1875 part = 0; layer = 3; mat = 0;
1882 if(2310*mm<=mr[2]&&mr[2]<2350*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1883 part = 0; layer = 3; mat = 1;
1890 if(2350*mm<=mr[2]&&mr[2]<2380*mm&&1167*mm<=mr[0]&&mr[0]<=2500*mm) {
1891 part = 0; layer = 4; mat = 0;
1898 if(2380*mm<=mr[2]&&mr[2]<2420*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1899 part = 0; layer = 4; mat = 1;
1906 if(2420*mm<=mr[2]&&mr[2]<2470*mm&&1203*mm<=mr[0]&&mr[0]<=2500*mm) {
1907 part = 0; layer = 5; mat = 0;
1914 if(2470*mm<=mr[2]&&mr[2]<2510*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1915 part = 0; layer = 5; mat =1;
1922 if(2510*mm<=mr[2]&&mr[2]<2590*mm&&1241*mm<=mr[0]&&mr[0]<=2500*mm) {
1923 part = 0; layer = 6; mat = 0;
1930 if(2590*mm<=mr[2]&&mr[2]<2630*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1931 part = 0; layer = 6; mat = 1;
1938 if(2630*mm<=mr[2]&&mr[2]<2710*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1939 part = 0; layer = 7; mat = 0;
1946 if(2710*mm<=mr[2]&&mr[2]<2750*mm&&1362*mm<=mr[0]&&mr[0]<=2500*mm) {
1947 part = 0; layer = 7; mat = 1;
1954 if(2750*mm<=mr[2]&&mr[2]<=2800*mm&&1302*mm<=mr[0]&&mr[0]<=2500*mm) {
1955 part = 0; layer = 8; mat = 0;
1963 if(ifbar==
true||ifend==
true) {
1964 if( r.x() < 0. && r.y() >= 0. && r.z() > 0. ){
1967 else if( r.x() <= 0. && r.y() < 0. && r.z() > 0. ){
1971 else if( r.x() > 0. && r.y() < 0. && r.z() > 0. ){
1974 else if( r.x() >= 0. && r.y() > 0. && r.z() < 0. ){
1978 else if( r.x() < 0. && r.y() >= 0. && r.z() < 0. ){
1981 else if( r.x() <= 0. && r.y() < 0. && r.z() < 0. ){
1985 else if( r.x() > 0. && r.y() <= 0. && r.z() < 0. ){
1992 newb[0] = -
b[0] * m_scale;
1993 newb[1] =
b[1] * m_scale;
1994 newb[2] = -
b[2] * m_scale;
2009 return StatusCode::SUCCESS;