#include <ShieldProjection.h>
Static Public Member Functions | |
| bool | GetProjection (const double *vtx, const double *dcos, int &nlayer, int &nsection, double *entrypoint, double *entrypoint2, double &shield_dcos, double &shield_dcos2, double &shieldpath) |
| void | SetPrint (int i=1) |
| void | PrintIntercept (const double vtxx, const double vtxy, const double vtxz, const double dcosx, const double dcosy, const double dcosz) |
Static Private Attributes | |
| int | fPrint = 0 |
|
||||||||||||||||||||||||||||||||||||||||
|
Definition at line 11 of file ShieldProjection.cxx. References SPRINT. Referenced by PrintIntercept(). 00024 {
00025 const double vtxu = 0.70710678*(vtx[0]+vtx[1]);
00026 const double vtxv = 0.70710678*(vtx[1]-vtx[0]);
00027 const double dcosu = 0.70710678*(dcos[0]+dcos[1]);
00028 const double dcosv = 0.70710678*(dcos[1]-dcos[0]);
00029
00030 SPRINT<< " DcosU"<< dcosu<< ", "<< "DCosV"<<dcosv<<endl;
00031 //Zero some output
00032 nlayer = 0;
00033 nsection = 0;
00034 shieldpath =0;
00035
00036 //work space
00037 double xzproj[3] = {-999., -999., -999.};
00038 double fShieldEntryDist = 99e99;
00039 double fShieldEntryDist2 = 99e99;
00040 int fIsHit =0;
00041
00042 if(fabs(dcos[1])>1e-6)
00043 {
00044 //TOP SECTION
00045 SPRINT<<"Trying top section"<<endl;
00046 xzproj[0] = vtx[0] + (dcos[0]/dcos[1])*(4.37 - vtx[1]); //x test intercept
00047 xzproj[1] = vtx[2] + (dcos[2]/dcos[1])*(4.37 - vtx[1]); //z test intercept
00048 SPRINT<<" Intercept Y,Z:"<< xzproj[0]<<", "<<xzproj[1]<<endl;
00049
00050 if(fabs(xzproj[0])<2.04 &&
00051 (4.37 - vtx[1])*dcos[1]> 0.0 //the correct side of the vtx // && (xzproj[1]>0.0 && xzproj[1]<31.02)
00052 ) //Actually under the shield
00053 {
00054 SPRINT<<" Section hit!"<<endl;
00055 fIsHit=1;
00056 const double tmpdist = sqrt((vtx[0] - xzproj[0])*(vtx[0] - xzproj[0])
00057 +(vtx[1] - 4.37)*(vtx[1] - 4.37)
00058 +(vtx[2] - xzproj[1])*(vtx[2] - xzproj[1]));
00059 if(nsection==0){
00060 fShieldEntryDist = tmpdist;
00061 entrypoint[0] =xzproj[0];
00062 entrypoint[1] =4.37;
00063 entrypoint[2] =xzproj[1];
00064 shield_dcos = fabs(dcos[0]);
00065 }else if( nsection && tmpdist<fShieldEntryDist){
00066 fShieldEntryDist2 = fShieldEntryDist;
00067 entrypoint2[0] = entrypoint[0];
00068 entrypoint2[1] = entrypoint[1] ;
00069 entrypoint2[2] = entrypoint[2];
00070 shield_dcos2 = shield_dcos;
00071 fShieldEntryDist = tmpdist;
00072 entrypoint[0] = xzproj[0];
00073 entrypoint[1] = 4.37;
00074 entrypoint[2] = xzproj[1];
00075 shield_dcos = fabs(dcos[1]);
00076 }else if((nsection==1 && tmpdist>fShieldEntryDist) || (nsection==2 && tmpdist<fShieldEntryDist2) ){
00077 fShieldEntryDist2 = tmpdist;
00078 entrypoint2[0] = xzproj[0];
00079 entrypoint2[1] = 4.37;
00080 entrypoint2[2] = xzproj[1];
00081 shield_dcos2 = fabs(dcos[1]);
00082 }
00083 nlayer+=2; //double layer on top
00084 shieldpath+= 2*fabs(dcos[1]);
00085 nsection++;
00086 }
00087
00088 //FLAT WINGS
00089 SPRINT<<"Trying flat wings section"<<endl;
00090 xzproj[0] = vtx[0] + (dcos[0]/dcos[1])*(3.06 - vtx[1]); //x test intercept
00091 xzproj[1] = vtx[2] + (dcos[2]/dcos[1])*(3.06 - vtx[1]); //z test intercept
00092 SPRINT<<" Intercept Y,Z:"<< xzproj[0]<<", "<<xzproj[1]<<endl;
00093 if(fabs(xzproj[0])<6.05 && fabs(xzproj[0])>3.34 &&
00094 // ((vtx[2] - xzproj[1])*dcos[2])<0.0 && //the correct side of the shield
00095 (3.06 - vtx[1])*dcos[1]> 0.0 // && //the correct side of the shield
00096 // (xzproj[1]>0.0 && xzproj[1]<31.02)
00097 ) //Actually under the shield
00098 {
00099 SPRINT<<" Section hit!"<<endl;fIsHit=1;
00100 const double tmpdist = sqrt((vtx[0] - xzproj[0])*(vtx[0] - xzproj[0])
00101 +(vtx[1] - 3.06)*(vtx[1] - 3.06)
00102 +(vtx[2] - xzproj[1])*(vtx[2] - xzproj[1]));
00103 if(nsection==0){
00104 fShieldEntryDist = tmpdist;
00105 entrypoint[0] =xzproj[0];
00106 entrypoint[1] =3.06;
00107 entrypoint[2] =xzproj[1];
00108 shield_dcos = fabs(dcos[1]);
00109 }else if( nsection && tmpdist<fShieldEntryDist){
00110 fShieldEntryDist2 = fShieldEntryDist;
00111 entrypoint2[0] = entrypoint[0];
00112 entrypoint2[1] = entrypoint[1] ;
00113 entrypoint2[2] = entrypoint[2];
00114 shield_dcos2 = shield_dcos;
00115 fShieldEntryDist = tmpdist;
00116 entrypoint[0] = xzproj[0];
00117 entrypoint[1] = 3.06;
00118 entrypoint[2] = xzproj[1];
00119 shield_dcos = fabs(dcos[1]);
00120 }else if((nsection==1 && tmpdist>fShieldEntryDist) || (nsection==2 && tmpdist<fShieldEntryDist2) ){
00121 fShieldEntryDist2 = tmpdist;
00122 entrypoint2[0] = xzproj[0];
00123 entrypoint2[1] = 3.06;
00124 entrypoint2[2] = xzproj[1];
00125 shield_dcos2 = fabs(dcos[1]);
00126 }
00127 nlayer+=2; //double layer on top
00128 shieldpath+= 2*fabs(dcos[1]);
00129 nsection++;
00130 }
00131 }
00132 if(fabs(dcos[0])>1e-6)
00133 {
00134 //LOWER WALL SECTION - EAST
00135 SPRINT<<"Trying lower east wall section"<<endl;
00136 xzproj[0] = vtx[1] + (dcos[1]/dcos[0])*(4.3 - vtx[0]); //y test intercept
00137 xzproj[1] = vtx[2] + (dcos[2]/dcos[0])*(4.3 - vtx[0]); //z test intercept
00138 SPRINT<<" Intercept Y,Z:"<< xzproj[0]<<", "<<xzproj[1]<<endl;
00139 if( xzproj[0] <=0.5 && xzproj[0]>=-1.5 &&
00140 (4.3 - vtx[0])*dcos[0]> 0.0 //&& //the correct side of the shield
00141 //(xzproj[1]>0.0 && xzproj[1]<31.02)
00142 ) //Actually under the shield
00143 {
00144 SPRINT<<" Section hit!"<<endl;
00145 fIsHit=1;
00146 const double tmpdist = sqrt((vtx[1] - xzproj[0])*(vtx[1] - xzproj[0])
00147 +(vtx[0] - 4.3)*(vtx[0] - 4.3)
00148 +(vtx[2] - xzproj[1])*(vtx[2] - xzproj[1]));
00149 if(nsection==0){
00150 fShieldEntryDist = tmpdist;
00151 entrypoint[1] =xzproj[0];
00152 entrypoint[0] =4.3;
00153 entrypoint[2] =xzproj[1];
00154 shield_dcos = fabs(dcos[0]);
00155 }else if( nsection && tmpdist<fShieldEntryDist){
00156 fShieldEntryDist2 = fShieldEntryDist;
00157 entrypoint2[0] = entrypoint[0];
00158 entrypoint2[1] = entrypoint[1] ;
00159 entrypoint2[2] = entrypoint[2];
00160 shield_dcos2 = shield_dcos;
00161 fShieldEntryDist = tmpdist;
00162 entrypoint[1] = xzproj[0];
00163 entrypoint[0] = 4.3;
00164 entrypoint[2] = xzproj[1];
00165 shield_dcos = fabs(dcos[0]);
00166 }else if((nsection==1 && tmpdist>fShieldEntryDist) || (nsection==2 && tmpdist<fShieldEntryDist2) ){
00167 fShieldEntryDist2 = tmpdist;
00168 entrypoint2[1] = xzproj[0];
00169 entrypoint2[0] = 4.3;
00170 entrypoint2[2] = xzproj[1];
00171 shield_dcos2 = fabs(dcos[0]);
00172 }
00173 nlayer+=1; //single layer on walls
00174 ++nsection;
00175 shieldpath+= fabs(dcos[0]);
00176 }
00177 //LOWER WALL SECTION - WEST
00178 SPRINT<<"Trying lower west wall section"<<endl;
00179 xzproj[0] = vtx[1] + (dcos[1]/dcos[0])*(-4.3 - vtx[0]); //y test intercept
00180 xzproj[1] = vtx[2] + (dcos[2]/dcos[0])*(-4.3 - vtx[0]); //z test intercept
00181 SPRINT<<" Intercept Y,Z:"<< xzproj[0]<<", "<<xzproj[1]<<endl;
00182 if( xzproj[0] <=0.5 && xzproj[0]>=-1.5 &&
00183 (-4.3 - vtx[0])*dcos[0]> 0.0 //the correct side of the shield
00184 //&&(xzproj[1]>0.0 && xzproj[1]<31.02)
00185 ) //Actually under the shield
00186 {
00187 SPRINT<<" Section hit!"<<endl;
00188 fIsHit=1;
00189 const double tmpdist = sqrt((vtx[1] - xzproj[0])*(vtx[1] - xzproj[0])
00190 +(vtx[0] + 4.3)*(vtx[0] + 4.3)
00191 +(vtx[2] - xzproj[1])*(vtx[2] - xzproj[1]));
00192 if(nsection==0){
00193 fShieldEntryDist = tmpdist;
00194 entrypoint[1] =xzproj[0];
00195 entrypoint[0] =-4.3;
00196 entrypoint[2] =xzproj[1];
00197 shield_dcos = fabs(dcos[0]);
00198 }else if( nsection && tmpdist<fShieldEntryDist){
00199 fShieldEntryDist2 = fShieldEntryDist;
00200 entrypoint2[0] = entrypoint[0];
00201 entrypoint2[1] = entrypoint[1] ;
00202 entrypoint2[2] = entrypoint[2];
00203 shield_dcos2 = shield_dcos;
00204 fShieldEntryDist = tmpdist;
00205 entrypoint[1] = xzproj[0];
00206 entrypoint[0] = -4.3;
00207 entrypoint[2] = xzproj[1];
00208 shield_dcos = fabs(dcos[0]);
00209 }else if((nsection==1 && tmpdist>fShieldEntryDist) || (nsection==2 && tmpdist<fShieldEntryDist2) ){
00210 fShieldEntryDist2 = tmpdist;
00211 entrypoint2[1] = xzproj[0];
00212 entrypoint2[0] = -4.3;
00213 entrypoint2[2] = xzproj[1];
00214 shield_dcos2 = fabs(dcos[0]);
00215 }
00216 nlayer+=1; //single layer on walls
00217 ++nsection;
00218 shieldpath+= fabs(dcos[0]);
00219 }
00220 //
00221 //UPPER WALL SECTION - EAST
00222 SPRINT<<"Trying upper east wall section"<<endl;
00223 xzproj[0] = vtx[1] + (dcos[1]/dcos[0])*(6.7 - vtx[0]); //y test intercept
00224 xzproj[1] = vtx[2] + (dcos[2]/dcos[0])*(6.7 - vtx[0]); //z test intercept
00225 SPRINT<<" Intercept Y,Z:"<< xzproj[0]<<", "<<xzproj[1]<<endl;
00226 if( xzproj[0] <=4.64 && xzproj[0]>=1.2 &&
00227 (6.7 - vtx[0])*dcos[0]> 0.0 //the correct side of the shield
00228 // && (xzproj[1]>0.0 && xzproj[1]<31.02)
00229 ) //Actually under the shield
00230 {
00231 SPRINT<<" Section hit!"<<endl;
00232 fIsHit=1;
00233 const double tmpdist = sqrt((vtx[1] - xzproj[0])*(vtx[1] - xzproj[0])
00234 +(vtx[0] - 6.7)*(vtx[0] - 6.7)
00235 +(vtx[2] - xzproj[1])*(vtx[2] - xzproj[1]));
00236 if(nsection==0){
00237 fShieldEntryDist = tmpdist;
00238 entrypoint[1] =xzproj[0];
00239 entrypoint[0] =6.7;
00240 entrypoint[2] =xzproj[1];
00241 shield_dcos = fabs(dcos[0]);
00242 }else if( nsection && tmpdist<fShieldEntryDist){
00243 fShieldEntryDist2 = fShieldEntryDist;
00244 entrypoint2[0] = entrypoint[0];
00245 entrypoint2[1] = entrypoint[1] ;
00246 entrypoint2[2] = entrypoint[2];
00247 shield_dcos2 = shield_dcos;
00248 fShieldEntryDist = tmpdist;
00249 entrypoint[1] = xzproj[0];
00250 entrypoint[0] = 6.7;
00251 entrypoint[2] = xzproj[1];
00252 shield_dcos = fabs(dcos[0]);
00253 }else if((nsection==1 && tmpdist>fShieldEntryDist) || (nsection==2 && tmpdist<fShieldEntryDist2) ){
00254 fShieldEntryDist2 = tmpdist;
00255 entrypoint2[1] = xzproj[0];
00256 entrypoint2[0] = 6.7;
00257 entrypoint2[2] = xzproj[1];
00258 shield_dcos2 = fabs(dcos[0]);
00259 }
00260 nlayer+=1; //single layer on walls
00261 ++nsection;
00262 shieldpath+= fabs(dcos[0]);
00263 }
00264 //UPPER WALL SECTION - WEST
00265 SPRINT<<"Trying upper wall west"<<endl;
00266 xzproj[0] = vtx[1] + (dcos[1]/dcos[0])*(-6.7 - vtx[0]); //y test intercept
00267 xzproj[1] = vtx[2] + (dcos[2]/dcos[0])*(-6.7 - vtx[0]); //z test intercept
00268 SPRINT<<" Intercept Y,Z:"<< xzproj[0]<<", "<<xzproj[1]<<endl;
00269 if( xzproj[0] <=4.64 && xzproj[0]>=1.2 &&
00270 (-6.7 - vtx[0])*dcos[0]> 0.0 //the correct side of the shield
00271 // && (xzproj[1]>0.0 && xzproj[1]<31.02)
00272 ) //Actually under the shield
00273 {
00274 SPRINT<<" Section hit!"<<endl;
00275 fIsHit=1;
00276 const double tmpdist = sqrt((vtx[1] - xzproj[0])*(vtx[1] - xzproj[0])
00277 +(vtx[0] + 6.7)*(vtx[0] + 6.7)
00278 +(vtx[2] - xzproj[1])*(vtx[2] - xzproj[1]));
00279
00280 if(nsection==0){
00281 fShieldEntryDist = tmpdist;
00282 entrypoint[1] =xzproj[0];
00283 entrypoint[0] =-6.7;
00284 entrypoint[2] =xzproj[1];
00285 shield_dcos = fabs(dcos[0]);
00286 }else if( nsection && tmpdist<fShieldEntryDist){
00287 fShieldEntryDist2 = fShieldEntryDist;
00288 entrypoint2[0] = entrypoint[0];
00289 entrypoint2[1] = entrypoint[1] ;
00290 entrypoint2[2] = entrypoint[2];
00291 shield_dcos2 = shield_dcos;
00292 fShieldEntryDist = tmpdist;
00293 entrypoint[1] = xzproj[0];
00294 entrypoint[0] = -6.7;
00295 entrypoint[2] = xzproj[1];
00296 shield_dcos = fabs(dcos[0]);
00297 }else if((nsection==1 && tmpdist>fShieldEntryDist) || (nsection==2 && tmpdist<fShieldEntryDist2) ){
00298 fShieldEntryDist2 = tmpdist;
00299 entrypoint2[1] = xzproj[0];
00300 entrypoint2[0] = -6.7;
00301 entrypoint2[2] = xzproj[1];
00302 shield_dcos2 = fabs(dcos[0]);
00303 }
00304 nlayer+=1; //single layer on walls
00305 ++nsection;
00306 shieldpath+= shield_dcos;
00307 shieldpath+= fabs(dcos[0]);
00308 }
00309 }
00310 if((dcosu)>1e-6)
00311 {
00312 //WING SLOPE - WEST
00313 SPRINT<<"Trying wing slope west"<<endl;
00314 xzproj[0] = vtxv + (dcosv/dcosu)*(4.45 - vtxu); //y test intercept
00315 xzproj[1] = vtx[2] + (dcos[2]/dcosu)*(4.45 - vtxu); //z test intercept
00316 SPRINT<<" Intercept V,Z:"<< xzproj[0]<<", "<<xzproj[1]<<endl;
00317 if( xzproj[0] <=1.5554 && xzproj[0]>=-0.22 &&
00318 (4.45 - vtxu)*dcosu> 0.0 //the correct side of the shield
00319 //&& (xzproj[1]>0.0 && xzproj[1]<31.02)
00320 ) //Actually under the shield
00321 {
00322 SPRINT<<" Section hit!"<<endl;
00323 fIsHit=1;
00324 const double tmpdist = sqrt((vtxv - xzproj[0])*(vtxv - xzproj[0])
00325 + (vtxu - 6.7)*(vtxu - 6.7)
00326 + (vtx[2] - xzproj[1])*(vtx[2] - xzproj[1]));
00327 if(nsection==0){
00328 fShieldEntryDist = tmpdist;
00329 entrypoint[1] =0.70710678*(4.45 + xzproj[0]);
00330 entrypoint[0] = 0.70710678*(4.45 - xzproj[0]);
00331 entrypoint[2] =xzproj[1];
00332 shield_dcos = fabs(dcosu);
00333 }else if( nsection && tmpdist<fShieldEntryDist){
00334 fShieldEntryDist2 = fShieldEntryDist;
00335 entrypoint2[0] = entrypoint[0];
00336 entrypoint2[1] = entrypoint[1] ;
00337 entrypoint2[2] = entrypoint[2];
00338 shield_dcos2 = shield_dcos;
00339 fShieldEntryDist = tmpdist;
00340 entrypoint[1] = 0.70710678*(4.45 + xzproj[0]);
00341 entrypoint[0] = 0.70710678*(4.45 - xzproj[0]);
00342 entrypoint[2] = xzproj[1];
00343 shield_dcos = fabs(dcosu);
00344 }else if((nsection==1 && tmpdist>fShieldEntryDist) ||
00345 (nsection==2 && tmpdist<fShieldEntryDist2) ){
00346 fShieldEntryDist2 = tmpdist;
00347 entrypoint2[1] = 0.70710678*(4.45 + xzproj[0]);
00348 entrypoint2[0] = 0.70710678*(4.45 - xzproj[0]);
00349 entrypoint2[2] = xzproj[1];
00350 shield_dcos2 = fabs(dcosu);
00351 }
00352 nlayer+=1; //single layer on walls
00353 ++nsection;
00354 shieldpath+= fabs(dcosu);
00355 }
00356 }
00357 if(dcosv!=0.0)
00358 {
00359 //WING SLOPE - EAST
00360 SPRINT<<"Trying wing slope east"<<endl;
00361 xzproj[0] = vtxu + (dcosu/dcosv)*(4.45 - vtxv); //y test intercept
00362 xzproj[1] = vtx[2] + (dcos[2]/dcosv)*(4.45 - vtxv); //z test intercept
00363 SPRINT<<" Intercept U,Z:"<< xzproj[0]<<", "<<xzproj[1]<<endl;
00364 if( xzproj[0] <=1.5554 && xzproj[0]>=-0.22 &&
00365 (4.45 - vtxv)*dcosv> 0.0 //the correct side of the shield
00366 // && (xzproj[1]>0.0 && xzproj[1]<31.02)
00367 ) //Actually under the shield
00368 {
00369 SPRINT<<" Section hit!"<<endl;
00370 fIsHit=1;
00371 const double tmpdist = sqrt((vtxu - xzproj[0])*(vtxu - xzproj[0])
00372 +(vtxv - 6.7)*(vtxv - 6.7)
00373 +(vtx[2] - xzproj[1])*(vtx[2] - xzproj[1]));
00374 if(nsection==0){
00375 fShieldEntryDist = tmpdist;
00376 entrypoint[1] = 0.70710678*( 4.45 + xzproj[0]);
00377 entrypoint[0] = 0.70710678*(-4.45 + xzproj[0]);
00378 entrypoint[2] =xzproj[1];
00379 shield_dcos = fabs(dcosv);
00380 }else if( nsection && tmpdist<fShieldEntryDist){
00381 fShieldEntryDist2 = fShieldEntryDist;
00382 entrypoint2[0] = entrypoint[0];
00383 entrypoint2[1] = entrypoint[1] ;
00384 entrypoint2[2] = entrypoint[2];
00385 shield_dcos2 = shield_dcos;
00386 fShieldEntryDist = tmpdist;
00387 entrypoint[1] = 0.70710678*( 4.45 + xzproj[0]);
00388 entrypoint[0] = 0.70710678*(-4.45 + xzproj[0]);
00389 entrypoint[2] = xzproj[1];
00390 shield_dcos = fabs(dcosv);
00391 }else if((nsection==1 && tmpdist>fShieldEntryDist) || (nsection==2 && tmpdist<fShieldEntryDist2) ){
00392 fShieldEntryDist2 = tmpdist;
00393 entrypoint2[1] = 0.70710678*( 4.45 + xzproj[0]);
00394 entrypoint2[0] = 0.70710678*(-4.45 + xzproj[0]);
00395 entrypoint2[2] = xzproj[1];
00396 shield_dcos2 = fabs(dcosv);
00397 }
00398 nlayer+=1; //single layer on walls
00399 ++nsection;
00400 shieldpath+= fabs(dcosv);
00401 }
00402 }
00403 return (fIsHit);
00404 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 414 of file ShieldProjection.cxx. References GetProjection(). 00415 {
00416 const double vtx[3] = {vtxx, vtxy, vtxz};
00417 const double dcos[3] = {dcosx, dcosy, dcosz};
00418 int nlayer=0;
00419 int nsection=0;
00420 double ep[3] = {-999., -999., -999.};
00421 double ep2[3]= {-999., -999., -999.};
00422 double epdc=-999.;
00423 double epdc2=-999.;
00424 double path=-999.;
00425 GetProjection(vtx, dcos, nlayer, nsection, ep, ep2, epdc, epdc2, path);
00426 cout<< "NLayers: "<< nlayer<<endl;
00427 cout<< "NSection: "<< nsection<<endl;
00428 cout<< "EP1: "<< ep[0]<<", "<<ep[1]<<", "<<ep[2]<<endl;
00429 cout<< "EP2: "<< ep2[0]<<", "<<ep2[1]<<", "<<ep2[2]<<endl;
00430
00431 }
|
|
|
Definition at line 408 of file ShieldProjection.cxx. References fPrint. 00409 {
00410 fPrint = i;
00411 }
|
|
|
Definition at line 406 of file ShieldProjection.cxx. Referenced by SetPrint(). |
1.3.9.1